Files
sx/examples/diagnostics/1177-diagnostics-addr-of-const-rejected.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

19 lines
794 B
Plaintext

// Taking the address of a scalar `::` constant is a compile error: a scalar
// constant folds to its value and has NO storage (only array/struct constants
// are immutable globals with a real address — see 0177). Covers a module-scope
// const, a local const, and an inline-asm `-> @const` write-through (the path
// that surfaced the bug). Before the fix, `@N` lowered to `inttoptr (i64 40 to
// ptr)` — a wild pointer that segfaulted on deref and emitted invalid stores
// for asm `-> @const`. Regression (issue 0138).
takes :: (p: *i64) {}
N :: 40;
main :: () {
takes(@N); // module scalar const — no storage
x :: 7;
takes(@x); // local scalar const — no storage
asm volatile { "mov %[c], #99", [c] "=r" -> @N }; // write-through to a const
}