mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 00:26:57 +00:00
fix wrong int alignment for i65..i127 on x86 arch
This commit is contained in:
parent
107d4f6683
commit
e89d6fc503
@ -340,7 +340,7 @@ pub const Mutable = struct {
|
||||
}
|
||||
|
||||
const req_limbs = calcTwosCompLimbCount(bit_count);
|
||||
const bit = @as(Log2Limb, @truncate(bit_count - 1));
|
||||
const bit: Log2Limb = @truncate(bit_count - 1);
|
||||
const signmask = @as(Limb, 1) << bit; // 0b0..010..0 where 1 is the sign bit.
|
||||
const mask = (signmask << 1) -% 1; // 0b0..011..1 where the leftmost 1 is the sign bit.
|
||||
|
||||
@ -2186,7 +2186,7 @@ pub const Const = struct {
|
||||
return if (self.positive) @as(T, @intCast(r)) else error.NegativeIntoUnsigned;
|
||||
} else {
|
||||
if (self.positive) {
|
||||
return @as(T, @intCast(r));
|
||||
return @intCast(r);
|
||||
} else {
|
||||
if (math.cast(T, r)) |ok| {
|
||||
return -ok;
|
||||
|
@ -1545,7 +1545,7 @@ pub const Type = struct {
|
||||
0 => .none,
|
||||
1...8 => .@"1",
|
||||
9...16 => .@"2",
|
||||
17...127 => .@"4",
|
||||
17...64 => .@"4",
|
||||
else => .@"16",
|
||||
},
|
||||
.x86_64 => switch (bits) {
|
||||
|
@ -1077,3 +1077,13 @@ test "result location initialization of error union with OPV payload" {
|
||||
_ = &c;
|
||||
try expectEqual(0, (c catch return error.TestFailed).x);
|
||||
}
|
||||
|
||||
test "return error union with i65" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
|
||||
try expect(try add(1000, 234) == 1234);
|
||||
}
|
||||
|
||||
fn add(x: i65, y: i65) anyerror!i65 {
|
||||
return x + y;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user