From 20925f2957d6b3c4f8ac99c5cc96fb18f0612e4d Mon Sep 17 00:00:00 2001 From: mlugg Date: Thu, 18 Sep 2025 20:24:31 +0100 Subject: [PATCH] Revert "frontend: another packedStructFieldPtrInfo fix" This reverts commit dedccecda944f88a5278c12c24ffbea46126de63. --- src/Type.zig | 5 ++++- test/behavior/union.zig | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Type.zig b/src/Type.zig index 699bc5159d..cdce964356 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -3540,7 +3540,10 @@ pub fn packedStructFieldPtrInfo( parent_ptr_info.packed_offset.host_size, parent_ptr_info.packed_offset.bit_offset + bit_offset, } else .{ - @intCast(struct_ty.abiSize(zcu)), + switch (zcu.comp.getZigBackend()) { + else => (running_bits + 7) / 8, + .stage2_x86_64 => @intCast(struct_ty.abiSize(zcu)), + }, bit_offset, }; diff --git a/test/behavior/union.zig b/test/behavior/union.zig index 874f86f10c..b4477990aa 100644 --- a/test/behavior/union.zig +++ b/test/behavior/union.zig @@ -1548,9 +1548,13 @@ test "packed union field pointer has correct alignment" { const bp = &b.u.x; const cp = &c.u.x; - comptime assert(@TypeOf(ap) == *align(4:2:@sizeOf(S)) u20); - comptime assert(@TypeOf(bp) == *align(1:2:@sizeOf(S)) u20); - comptime assert(@TypeOf(cp) == *align(64:2:@sizeOf(S)) u20); + const host_size = switch (builtin.zig_backend) { + else => comptime std.math.divCeil(comptime_int, @bitSizeOf(S), 8) catch unreachable, + .stage2_x86_64 => @sizeOf(S), + }; + comptime assert(@TypeOf(ap) == *align(4:2:host_size) u20); + comptime assert(@TypeOf(bp) == *align(1:2:host_size) u20); + comptime assert(@TypeOf(cp) == *align(64:2:host_size) u20); a.u = .{ .x = 123 }; b.u = .{ .x = 456 };