mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
frontend: another packedStructFieldPtrInfo fix
it was calculating host integer size in a wrong way. just use integer abi size
This commit is contained in:
parent
baaf715d21
commit
5d8c1fb6ab
@ -3540,10 +3540,7 @@ pub fn packedStructFieldPtrInfo(
|
|||||||
parent_ptr_info.packed_offset.host_size,
|
parent_ptr_info.packed_offset.host_size,
|
||||||
parent_ptr_info.packed_offset.bit_offset + bit_offset,
|
parent_ptr_info.packed_offset.bit_offset + bit_offset,
|
||||||
} else .{
|
} else .{
|
||||||
switch (zcu.comp.getZigBackend()) {
|
@intCast(struct_ty.abiSize(zcu)),
|
||||||
else => (running_bits + 7) / 8,
|
|
||||||
.stage2_x86_64 => @intCast(struct_ty.abiSize(zcu)),
|
|
||||||
},
|
|
||||||
bit_offset,
|
bit_offset,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1547,13 +1547,9 @@ test "packed union field pointer has correct alignment" {
|
|||||||
const bp = &b.u.x;
|
const bp = &b.u.x;
|
||||||
const cp = &c.u.x;
|
const cp = &c.u.x;
|
||||||
|
|
||||||
const host_size = switch (builtin.zig_backend) {
|
comptime assert(@TypeOf(ap) == *align(4:2:@sizeOf(S)) u20);
|
||||||
else => comptime std.math.divCeil(comptime_int, @bitSizeOf(S), 8) catch unreachable,
|
comptime assert(@TypeOf(bp) == *align(1:2:@sizeOf(S)) u20);
|
||||||
.stage2_x86_64 => @sizeOf(S),
|
comptime assert(@TypeOf(cp) == *align(64:2:@sizeOf(S)) u20);
|
||||||
};
|
|
||||||
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 };
|
a.u = .{ .x = 123 };
|
||||||
b.u = .{ .x = 456 };
|
b.u = .{ .x = 456 };
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user