zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 9694c83b954d1bd4a3f224ef69d75639e6da56c7 (tree)
parent d07b67a55cba683c7adb73f5e2f7b1bec803a361
Author: Alex Rønne Petersen <alex@alexrp.com>
Date:   Mon, 22 Sep 2025 04:56:46 +0200

Revert "frontend: another packedStructFieldPtrInfo fix"

This reverts commit 3ab845e028f464666856e4eaaeff2e6ab1b3da5d.

Diffstat:
Msrc/Type.zig | 5++++-
Mtest/behavior/union.zig | 10+++++++---
2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/Type.zig b/src/Type.zig @@ -3545,7 +3545,10 @@ pub fn packedStructFieldPtrInfo(struct_ty: Type, parent_ptr_ty: Type, field_idx: 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 @@ -1564,9 +1564,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 };