From 592f1043dc704faf79bde7149917d4155b3747f8 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sat, 19 Jul 2025 13:54:31 -0400 Subject: [PATCH] cbe: fix comptime-known packed unions --- src/codegen/c.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 955a83bc33..c726c05e1b 100644 --- a/src/codegen/c.zig +++ b/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,