authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-09-10 14:56:04-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-09-20 18:33:01-07:00
log5d8c1fb6ab6972691f0bc9ecc8b3233430884361
treef93afe6ef4c42f82237edd6b0ec025fc202808b8
parentbaaf715d210e8a25598161cd2bc7a510c39b8a95

frontend: another packedStructFieldPtrInfo fix

it was calculating host integer size in a wrong way. just use integer abi size

2 files changed, 4 insertions(+), 11 deletions(-)

src/Type.zig+1-4
......@@ -3540,10 +3540,7 @@ pub fn packedStructFieldPtrInfo(
35403540 parent_ptr_info.packed_offset.host_size,
35413541 parent_ptr_info.packed_offset.bit_offset + bit_offset,
35423542 } else .{
3543 switch (zcu.comp.getZigBackend()) {
3544 else => (running_bits + 7) / 8,
3545 .stage2_x86_64 => @intCast(struct_ty.abiSize(zcu)),
3546 },
3543 @intCast(struct_ty.abiSize(zcu)),
35473544 bit_offset,
35483545 };
35493546
test/behavior/union.zig+3-7
......@@ -1547,13 +1547,9 @@ test "packed union field pointer has correct alignment" {
15471547 const bp = &b.u.x;
15481548 const cp = &c.u.x;
15491549
1550 const host_size = switch (builtin.zig_backend) {
1551 else => comptime std.math.divCeil(comptime_int, @bitSizeOf(S), 8) catch unreachable,
1552 .stage2_x86_64 => @sizeOf(S),
1553 };
1554 comptime assert(@TypeOf(ap) == *align(4:2:host_size) u20);
1555 comptime assert(@TypeOf(bp) == *align(1:2:host_size) u20);
1556 comptime assert(@TypeOf(cp) == *align(64:2:host_size) u20);
1550 comptime assert(@TypeOf(ap) == *align(4:2:@sizeOf(S)) u20);
1551 comptime assert(@TypeOf(bp) == *align(1:2:@sizeOf(S)) u20);
1552 comptime assert(@TypeOf(cp) == *align(64:2:@sizeOf(S)) u20);
15571553
15581554 a.u = .{ .x = 123 };
15591555 b.u = .{ .x = 456 };