diff options
| author | 2025-11-22 09:50:48 +0100 | |
|---|---|---|
| committer | 2025-11-22 09:50:48 +0100 | |
| commit | 79272697e025663d7a4e7972019f318fea8d18bf (patch) | |
| tree | e7f28e0cddd439700b6cc38ac993ef22b62edb56 /c | |
| parent | e471cfe5d94f47b7bcd95ce37e7d5c75997a7a67 (diff) | |
c: cast should narrow for narrow ints
Diffstat (limited to 'c')
| -rw-r--r-- | c/c.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -3227,9 +3227,10 @@ compileexpr(struct function *fn, const struct expr *ex, bool discard) case EPLUS: r = compileexpr(fn, sub, discard); if (discard) return NOREF; - if (isscalar(ex->ty) && typesize(ex->ty) < typesize(sub->ty)) + r = cvt(fn, ex->ty, sub->ty, r); + if (isint(ex->ty) && typesize(ex->ty) < typesize(sub->ty)) return narrow(fn, type2cls[scalartypet(ex->ty)], ex->ty, r, 0); - return cvt(fn, ex->ty, sub->ty, r); + return r; case ENEG: op = Oneg; goto Unary; |