Files
sx/examples/basic/0055-basic-large-stack-array.sx
agra 66bdc70bf1 test: group examples into per-category folders
Move examples/*.sx and their expected/ snapshots into per-category
subfolders (examples/<category>/...). Folder = leading filename token,
with ffi-objc/ffi-jni kept whole; filenames are unchanged. The corpus
runner and LSP sweep now discover each category's expected/ dir, while
issues/ stays flat. Example 1058's repo-root-relative companion import
is made file-relative. Path strings embedded in 164 snapshots were
regenerated (path-only changes). Test-layout docs in CLAUDE.md updated.
2026-06-21 14:41:34 +03:00

46 lines
1.1 KiB
Plaintext

// Large (64KB+) stack arrays compile and are accessed in place: `---`
// emits no initializer store, and element reads GEP the array's storage
// instead of loading the whole array as a value.
//
// Regression (issue 0124): both whole-aggregate shapes — the undef
// store from `---` and `index_get` on the loaded array value —
// scalarized into one SelectionDAG node per element and segfaulted
// `sx build` at [65536]u8.
//
// Results print via out/int_to_string: `{}` formatting would pull the
// any_to_string dispatcher, whose array arms materialize every interned
// array type BY VALUE — the separate issue 0125.
#import "modules/std.sx";
checksum :: () -> i64 {
buf : [65536]u8 = ---;
i := 0;
while i < 65536 {
buf[i] = xx (i % 251);
i += 1;
}
sum := 0;
i = 0;
while i < 65536 {
sum += xx buf[i];
i += 1;
}
return sum;
}
big :: () -> i64 {
buf : [131072]i64 = ---;
buf[0] = 11;
buf[131071] = 31;
return buf[0] + buf[131071];
}
main :: () -> i32 {
out(int_to_string(checksum()));
out("\n");
out(int_to_string(big()));
out("\n");
return 0;
}