Fix trailing padding in aggregate static initializers
authorRobert Pengelly <robertapengelly@hotmail.com>
Sat, 31 Oct 2026 10:20:35 +0000 (10:20 +0000)
committerRobert Pengelly <robertapengelly@hotmail.com>
Sat, 31 Oct 2026 10:20:35 +0000 (10:20 +0000)
parse.c

diff --git a/parse.c b/parse.c
index 394e24fe1af4d73888ada074ff6ba367d18be407..7b8bc9adf517ce08ec05f3d85622cc414629e888 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -3722,7 +3722,15 @@ void parse_type_spec (void) {
             }
             
             if (!aggregate_is_packed) {
-                aggregate_size = (int) align_up_long (aggregate_size, aggregate_align);
+            
+                int aligned_size = (int) align_up_long (aggregate_size, aggregate_align);
+                
+                if (!is_union && aligned_size > aggregate_size && aggregate_field_count < MAX_AGG_FIELDS) {
+                    aggregate_fields[aggregate_field_count++] = -(aligned_size - aggregate_size);
+                }
+                
+                aggregate_size = aligned_size;
+            
             }
             
             {