From f3dc6d68ae2bd82be59140d4d6a0af6d9bcfd077 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <vital.had@gmail.com>
Date: Tue, 11 Nov 2025 03:33:36 +0800
Subject: [PATCH 01/13] codegen, target: minor fix to struct logic

---
 src/trans/codegen_c.cpp | 5 ++++-
 src/trans/target.cpp    | 6 +++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index 19e04f6f..f8518ca4 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -1838,9 +1838,12 @@ namespace {
                             {
                                 field_align = 4;
                             }
-                            is_first_field = false;
                         }
                     }
+                    if( s > 0 )
+                    {
+                        is_first_field = false;
+                    }
                     a = packing_max_align > 0 ? std::min<size_t>(packing_max_align, field_align) : field_align;
                     DEBUG("a = " << a);
                     while(cur_ofs % a != 0)
diff --git a/src/trans/target.cpp b/src/trans/target.cpp
index 922ba13e..769ce96b 100644
--- a/src/trans/target.cpp
+++ b/src/trans/target.cpp
@@ -1090,10 +1090,14 @@ namespace {
                     {
                         align = 4;
                     }
-                    is_first_field = false;
                 }
             }
 
+            if ( e.size > 0 )
+            {
+                is_first_field = false;
+            }
+
             // Increase offset to fit alignment
             align = max_alignment > 0 ? std::min<size_t>(align, max_alignment) : align;
             if( align > 0 )
-- 
2.43.0

