nx_smoke_codegen_bug.nx source
↩ module page · 34 lines · 857 B
1// Minimal repro for the nested-if codegen bug:
2// outer if + 2 sequential inner ifs reading from the same struct
3// pointer crashes when run under qemu.
4
5// nx_safety_envelope:
6// intended_use: AUTO_APPLIED -- primitive-specific tuning queued
7// sil_target: SIL1
8// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail]
9// verdict: NOT_YET_EVALUATED
10
11import "nx_syscalls.nx"
12
13struct Cell {
14 a: i64,
15 b: i64,
16 c: i64,
17}
18
19func main() -> i64 {
20 let buf: *u8 = sys_mmap(64)
21 let p: *Cell = buf as *Cell
22 p.a = 5
23 p.b = 7
24 p.c = 11
25
26 var n: i64 = 0
27 while n < 3 {
28 if p.a >= 0 {
29 if p.b >= 0 { n = n + 1 }
30 if p.b < 0 { n = n + 100 } // dead branch, but presence triggers bug?
31 }
32 }
33 return __syscall(93, n & 0xFF, 0, 0, 0, 0, 0)
34}