mirror of
https://github.com/ziglang/zig.git
synced 2026-01-12 18:35:12 +00:00
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.
15 lines
364 B
Zig
15 lines
364 B
Zig
const std = @import("std");
|
|
|
|
// Stress test zerofill layout
|
|
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", .{
|
|
// workaround the dreaded decl_val
|
|
(&buffer)[0],
|
|
(&buffer)[0x10],
|
|
(&buffer)[0x1000000 - 1],
|
|
});
|
|
}
|