DEref fix
authorRobert Pengelly <robertapengelly@hotmail.com>
Sat, 15 Aug 2026 07:16:00 +0000 (08:16 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Sat, 15 Aug 2026 07:16:00 +0000 (08:16 +0100)
amd64.c
i386.c

diff --git a/amd64.c b/amd64.c
index d2c740af119ec58a11948f98a7679c8e013bf1c5..06ee84cfd4225fce8d4cb5b64dd7f6fac7685978 100644 (file)
--- 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 75e2a7ec300919a1a7af5582c731bb90a2800929..90dee0e4de7364e814f56ef8c0b58c1efacf3f11 100644 (file)
--- 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);
                 
                 {