authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-08 13:21:36-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-08 19:37:30-07:00
loge89d6fc5037f4271396cb6acf3488f158aaacbae
treef0d4bd09094b60e6df24db416029f52f87a853f5
parent107d4f668342cce492150ef8763f56008058f0bc

fix wrong int alignment for i65..i127 on x86 arch


3 files changed, 13 insertions(+), 3 deletions(-)

lib/std/math/big/int.zig+2-2
......@@ -340,7 +340,7 @@ pub const Mutable = struct {
340340 }
341341
342342 const req_limbs = calcTwosCompLimbCount(bit_count);
343 const bit = @as(Log2Limb, @truncate(bit_count - 1));
343 const bit: Log2Limb = @truncate(bit_count - 1);
344344 const signmask = @as(Limb, 1) << bit; // 0b0..010..0 where 1 is the sign bit.
345345 const mask = (signmask << 1) -% 1; // 0b0..011..1 where the leftmost 1 is the sign bit.
346346
......@@ -2186,7 +2186,7 @@ pub const Const = struct {
21862186 return if (self.positive) @as(T, @intCast(r)) else error.NegativeIntoUnsigned;
21872187 } else {
21882188 if (self.positive) {
2189 return @as(T, @intCast(r));
2189 return @intCast(r);
21902190 } else {
21912191 if (math.cast(T, r)) |ok| {
21922192 return -ok;
src/type.zig+1-1
......@@ -1545,7 +1545,7 @@ pub const Type = struct {
15451545 0 => .none,
15461546 1...8 => .@"1",
15471547 9...16 => .@"2",
1548 17...127 => .@"4",
1548 17...64 => .@"4",
15491549 else => .@"16",
15501550 },
15511551 .x86_64 => switch (bits) {
test/behavior/error.zig+10
......@@ -1077,3 +1077,13 @@ test "result location initialization of error union with OPV payload" {
10771077 _ = &c;
10781078 try expectEqual(0, (c catch return error.TestFailed).x);
10791079}
1080
1081test "return error union with i65" {
1082 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
1083
1084 try expect(try add(1000, 234) == 1234);
1085}
1086
1087fn add(x: i65, y: i65) anyerror!i65 {
1088 return x + y;
1089}