authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-09-10 14:56:04-07:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-09-21 21:08:52+02:00
log3ab845e028f464666856e4eaaeff2e6ab1b3da5d
tree5136997c2bde21445c1cfed42a0377be85f4d0c8
parentb4394412bb0f5d2ff0018fb9e868ccf0f46ab911
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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
...@@ -3545,10 +3545,7 @@ pub fn packedStructFieldPtrInfo(struct_ty: Type, parent_ptr_ty: Type, field_idx:...@@ -3545,10 +3545,7 @@ pub fn packedStructFieldPtrInfo(struct_ty: Type, parent_ptr_ty: Type, field_idx:
3545 parent_ptr_info.packed_offset.host_size,3545 parent_ptr_info.packed_offset.host_size,
3546 parent_ptr_info.packed_offset.bit_offset + bit_offset,3546 parent_ptr_info.packed_offset.bit_offset + bit_offset,
3547 } else .{3547 } else .{
3548 switch (zcu.comp.getZigBackend()) {3548 @intCast(struct_ty.abiSize(zcu)),
3549 else => (running_bits + 7) / 8,
3550 .stage2_x86_64 => @intCast(struct_ty.abiSize(zcu)),
3551 },
3552 bit_offset,3549 bit_offset,
3553 };3550 };
35543551
test/behavior/union.zig+3-7
...@@ -1564,13 +1564,9 @@ test "packed union field pointer has correct alignment" {...@@ -1564,13 +1564,9 @@ test "packed union field pointer has correct alignment" {
1564 const bp = &b.u.x;1564 const bp = &b.u.x;
1565 const cp = &c.u.x;1565 const cp = &c.u.x;
15661566
1567 const host_size = switch (builtin.zig_backend) {1567 comptime assert(@TypeOf(ap) == *align(4:2:@sizeOf(S)) u20);
1568 else => comptime std.math.divCeil(comptime_int, @bitSizeOf(S), 8) catch unreachable,1568 comptime assert(@TypeOf(bp) == *align(1:2:@sizeOf(S)) u20);
1569 .stage2_x86_64 => @sizeOf(S),1569 comptime assert(@TypeOf(cp) == *align(64:2:@sizeOf(S)) u20);
1570 };
1571 comptime assert(@TypeOf(ap) == *align(4:2:host_size) u20);
1572 comptime assert(@TypeOf(bp) == *align(1:2:host_size) u20);
1573 comptime assert(@TypeOf(cp) == *align(64:2:host_size) u20);
15741570
1575 a.u = .{ .x = 123 };1571 a.u = .{ .x = 123 };
1576 b.u = .{ .x = 456 };1572 b.u = .{ .x = 456 };