Commit 592f1043dc

Jacob Young <jacobly0@users.noreply.github.com>
2025-07-19 19:54:31
cbe: fix comptime-known packed unions
1 parent a0d1682
Changed files (1)
src
codegen
src/codegen/c.zig
@@ -2438,7 +2438,10 @@ pub const DeclGen = struct {
         const ty = val.typeOf(zcu);
         return .{ .data = .{
             .dg = dg,
-            .int_info = ty.intInfo(zcu),
+            .int_info = if (ty.zigTypeTag(zcu) == .@"union" and ty.containerLayout(zcu) == .@"packed")
+                .{ .signedness = .unsigned, .bits = @intCast(ty.bitSize(zcu)) }
+            else
+                ty.intInfo(zcu),
             .kind = kind,
             .ctype = try dg.ctypeFromType(ty, kind),
             .val = val,