From 437059f37cc4e7fb0f1398043a88b2d7a9363653 Mon Sep 17 00:00:00 2001 From: mlugg Date: Thu, 5 Jun 2025 12:15:56 +0100 Subject: [PATCH] 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. --- test/link/bss/main.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/link/bss/main.zig b/test/link/bss/main.zig index d2ecffe982..aaf865a0c8 100644 --- a/test/link/bss/main.zig +++ b/test/link/bss/main.zig @@ -6,8 +6,9 @@ var buffer: [0x1000000]u64 = [1]u64{0} ** 0x1000000; pub fn main() anyerror!void { buffer[0x10] = 1; try std.io.getStdOut().writer().print("{d}, {d}, {d}\n", .{ - buffer[0], - buffer[0x10], - buffer[0x1000000 - 1], + // workaround the dreaded decl_val + (&buffer)[0], + (&buffer)[0x10], + (&buffer)[0x1000000 - 1], }); }