Skip to content

Commit 592f104

Browse files
jacobly0andrewrk
authored andcommitted
cbe: fix comptime-known packed unions
1 parent a0d1682 commit 592f104

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/codegen/c.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2438,7 +2438,10 @@ pub const DeclGen = struct {
24382438
const ty = val.typeOf(zcu);
24392439
return .{ .data = .{
24402440
.dg = dg,
2441-
.int_info = ty.intInfo(zcu),
2441+
.int_info = if (ty.zigTypeTag(zcu) == .@"union" and ty.containerLayout(zcu) == .@"packed")
2442+
.{ .signedness = .unsigned, .bits = @intCast(ty.bitSize(zcu)) }
2443+
else
2444+
ty.intInfo(zcu),
24422445
.kind = kind,
24432446
.ctype = try dg.ctypeFromType(ty, kind),
24442447
.val = val,

0 commit comments

Comments
 (0)