i386/amd64: Fix structure assignment from dereferenced pointers
authorRobert Pengelly <robertapengelly@hotmail.com>
Thu, 8 Oct 2026 04:30:44 +0000 (05:30 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Thu, 8 Oct 2026 04:30:44 +0000 (05:30 +0100)
amd64.c
i386.c

diff --git a/amd64.c b/amd64.c
index 37673ed24de370ce06810c51da8cae46812bca39..540bf197637432acd37ca110c69d48fd4915a60d 100644 (file)
--- a/amd64.c
+++ b/amd64.c
@@ -32916,6 +32916,21 @@ static int parse_identifier_assignment_statement (void) {
         lhs_is_floating = lhs ? lhs->is_floating : get_global_symbol_floating (name);
         lhs_pointer_depth = lhs ? lhs->pointer_depth : get_global_symbol_pointer_depth (name);
         
+        if (is_simple_assign && lhs_size > (DATA_LLONG & 0x1f) && tok.kind == TOK_STAR) {
+        
+            emit_load_symbol_address_for_copy_now ("rdx", lhs, name);
+            
+            if (emit_aggregate_copy_from_current_rhs_to_addr_reg_now ("rdx", 0, lhs_size)) {
+            
+                expect_semi_or_recover ();
+                
+                free (name);
+                return 1;
+            
+            }
+        
+        }
+        
         if (is_simple_assign && lhs_size > (DATA_LLONG & 0x1f) && tok.kind == TOK_IDENT) {
             
             char *rhs_name = xstrdup (tok.ident);
diff --git a/i386.c b/i386.c
index 647e55030553d3a3d9d61e2d0c76114c98cdab43..6db590cdc7809e1de9cce34436dd128d7e3c2099 100644 (file)
--- a/i386.c
+++ b/i386.c
@@ -30369,6 +30369,21 @@ static int parse_identifier_assignment_statement (void) {
         lhs_size = lhs ? lhs->size : get_global_symbol_size (name);
         lhs_is_floating = lhs ? lhs->is_floating : get_global_symbol_floating (name);
         
+        if (is_simple_assign && lhs_size > (DATA_LLONG & 0x1f) && tok.kind == TOK_STAR) {
+        
+            emit_load_symbol_address_for_copy_now ("edx", lhs, name);
+            
+            if (emit_aggregate_copy_from_current_rhs_to_addr_reg_now ("edx", 0, lhs_size)) {
+            
+                expect_semi_or_recover ();
+                
+                free (name);
+                return 1;
+            
+            }
+        
+        }
+        
         if (is_simple_assign && lhs_size > (DATA_LLONG & 0x1f) && tok.kind == TOK_IDENT) {
             
             char *rhs_name = xstrdup (tok.ident);