Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/type.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3596,12 +3596,12 @@ pub const Type = extern union {

fn intAbiSize(bits: u16, target: Target) u64 {
const alignment = intAbiAlignment(bits, target);
return std.mem.alignForwardGeneric(u64, (bits + 7) / 8, alignment);
return std.mem.alignForwardGeneric(u64, @intCast(u16, (@as(u17, bits) + 7) / 8), alignment);
}

fn intAbiAlignment(bits: u16, target: Target) u32 {
return @min(
std.math.ceilPowerOfTwoPromote(u16, (bits + 7) / 8),
std.math.ceilPowerOfTwoPromote(u16, @intCast(u16, (@as(u17, bits) + 7) / 8)),
target.maxIntAlignment(),
);
}
Expand Down
21 changes: 21 additions & 0 deletions test/behavior/basic.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1124,3 +1124,24 @@ test "runtime-known globals initialized with undefined" {
try expect(S.s[0] == 1);
try expect(S.s[4] == 5);
}

test "arrays and vectors with big integers" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;

// TODO: only aarch64-windows didn't pass in the PR that added this code.
// figure out why if you can run this target.
if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64) return error.SkipZigTest;

inline for (.{ u65528, u65529, u65535 }) |Int| {
var a: [1]Int = undefined;
a[0] = std.math.maxInt(Int);
try expect(a[0] == comptime std.math.maxInt(Int));
var b: @Vector(1, Int) = undefined;
b[0] = std.math.maxInt(Int);
try expect(b[0] == comptime std.math.maxInt(Int));
}
}