Skip to content

Commit e89d6fc

Browse files
committed
fix wrong int alignment for i65..i127 on x86 arch
1 parent 107d4f6 commit e89d6fc

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

lib/std/math/big/int.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
1081+
test "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+
1087+
fn add(x: i65, y: i65) anyerror!i65 {
1088+
return x + y;
1089+
}

0 commit comments

Comments
 (0)