authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-06-05 12:15:56+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-06-06 23:42:15-07:00
log437059f37cc4e7fb0f1398043a88b2d7a9363653
tree3e7c5f555469bb5f4420a8a04251efd639683402
parent0bf8617d963dc432ed0204b10285cc414becf2fd

tests: avoid loading 16 MiB onto the stack

Currently, Zig semantically loads an array as a temporary when indexing it. This means it cannot be guaranteed that only the requested element is loaded; in particular, our self-hosted backends do not elide the load of the full array, so this test case was crashing on self-hosted.

1 files changed, 4 insertions(+), 3 deletions(-)

test/link/bss/main.zig+4-3
......@@ -6,8 +6,9 @@ var buffer: [0x1000000]u64 = [1]u64{0} ** 0x1000000;
66pub fn main() anyerror!void {
77 buffer[0x10] = 1;
88 try std.io.getStdOut().writer().print("{d}, {d}, {d}\n", .{
9 buffer[0],
10 buffer[0x10],
11 buffer[0x1000000 - 1],
9 // workaround the dreaded decl_val
10 (&buffer)[0],
11 (&buffer)[0x10],
12 (&buffer)[0x1000000 - 1],
1213 });
1314}