code wiki / (root) / nx_checked_arith_const.nx

nx_checked_arith_const.nx source

↩ module page · 17 lines · 803 B

1// nx_checked_arith_const.nx -- STANDING WITNESS for the COMPILE-TIME leg of LN1 checked 2// arithmetic (sibling of nx_checked_arith.nx; same family as nx_boundscheck_constidx.nx). 3// 4// 9223372036854775807 + 1 is a provable i64 overflow written in source. Under the DEFAULT build 5// this compiles clean and returns the WRAPPED value (MIN) -- the silent C-class behaviour, kept 6// as the hazard record. Under `--chkarith` the compiler REFUSES it at parse time with the 7// checked-arith-const-overflow diagnostic -- nx_chkarith_gate asserts both directions and that 8// the refusal names this rule, not some other error. 9// 10// license_tier: ORIGINAL No hw writes (Rule 26). 11import "nx_syscalls.nx" 12 13func main() -> i64 { 14 let x: i64 = 9223372036854775807 + 1 15 if x < 0 { return 0 } 16 return 1 17}