From: Robert Pengelly Date: Sat, 15 Aug 2026 07:16:00 +0000 (+0100) Subject: DEref fix X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=7f1261e3714637536df897057f6a6dfc358bc0ba;p=scc.git DEref fix --- diff --git a/amd64.c b/amd64.c index d2c740a..06ee84c 100644 --- a/amd64.c +++ b/amd64.c @@ -12590,6 +12590,24 @@ static void emit_load_assignment_rhs_to_pair (const char *lo, const char *hi) { } + /* + * A cast to a scalar type narrower than long long means the + * operand itself is a scalar expression, even when the final + * assignment destination is 64-bit. Keeping such operands in + * the pair parser makes unary forms such as (int) **p hit the + * pair parser's single-dereference-only TOK_STAR path. Parse + * the operand with the normal scalar parser and widen the cast + * result into the requested pair instead. + */ + if (!cast_is_pointer && !last_cast_type_is_floating && (cast_size & 0x1f) != (DATA_LLONG & 0x1f)) { + + emit_load_assignment_rhs_to_reg (lo); + emit_extend_pair_high_from_low (lo, hi, cast_size, cast_is_unsigned); + + return; + + } + emit_load_assignment_rhs_to_pair (lo, hi); { diff --git a/i386.c b/i386.c index 75e2a7e..90dee0e 100644 --- a/i386.c +++ b/i386.c @@ -11190,6 +11190,24 @@ static void emit_load_assignment_rhs_to_pair (const char *lo, const char *hi) { } + /* + * A cast to a scalar type narrower than long long means the + * operand itself is a scalar expression, even when the final + * assignment destination is 64-bit. Keeping such operands in + * the pair parser makes unary forms such as (int) **p hit the + * pair parser's single-dereference-only TOK_STAR path. Parse + * the operand with the normal scalar parser and widen the cast + * result into the requested pair instead. + */ + if (!cast_is_pointer && !last_cast_type_is_floating && (cast_size & 0x1f) != (DATA_LLONG & 0x1f)) { + + emit_load_assignment_rhs_to_reg (lo); + emit_extend_pair_high_from_low (lo, hi, cast_size, cast_is_unsigned); + + return; + + } + emit_load_assignment_rhs_to_pair (lo, hi); {