From 79272697e025663d7a4e7972019f318fea8d18bf Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 22 Nov 2025 09:50:48 +0100 Subject: c: cast should narrow for narrow ints --- c/c.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'c/c.c') diff --git a/c/c.c b/c/c.c index 5a0f5bd..ab477da 100644 --- a/c/c.c +++ b/c/c.c @@ -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; -- cgit v1.2.3