code wiki / _hdl_build / nx_doc_constscan.nx

nx_doc_constscan.nx

buildroot/runtime/_hdl_build/nx_doc_constscan.nx

6086 B122 linesdepth 3pulls 3 transitivereach 2 importersview sourcekind librarytopic doc
docsdependenciesstructsconstsfunctions

about

nx_doc_constscan.nx -- static detector for the LM-030 footgun (sibling of nx_doc_ubscan/LM-031): indexing a `const *T` global DIRECTLY in expression position -- CONST[i] -- silently miscompiles (it crashed nx_cc with a parser desync historically; today it returns a garbage value, measured: nx_doc_demo_const SM_LIB[2] ran 156 for expected 99). The fix-by-construction: bind the const to a local first (`let p = CONST; p[i]`) or pass it to a func that indexes its param. 2-pass: (1) collect every `const NAME: *...` pointer-const name; (2) flag any `NAME[` direct-index usage (the declaration is `NAME:` so it never matches). LINEAGE: the NISHI RECYCLER's hardening for the memory-safety/UB critiques (recyc_crit_ub.raw / recyc_crit_memsafety.raw). READ-ONLY. ORIGINAL

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_doc_heal_let.nx nx_doc_constscan.nx nx_doc_constscan_gate.nx nx_doc_constscan_run.nx

imports: nx_syscalls.nxnx_doc_heal_let.nx

imported by: nx_doc_constscan_gate.nxnx_doc_constscan_run.nx

structs

none

consts

none

functions

11func cs_skipws(src: *u8, n: i64, p0: i64) -> i64
called by 1: cs_record
17func cs_is_const_at(src: *u8, n: i64, i: i64) -> i64
called by 1: cs_scan calls 1: dhl_isident
29func cs_record(src: *u8, n: i64, i: i64, names: *u8, nlens: *i64, ncountp: *i64, capn: i64) -> i64
49func cs_is_const_name(names: *u8, nlens: *i64, ncount: i64, src: *u8, from: i64, len: i64) -> i64
called by 1: cs_scan
58func cs_scan(src: *u8, n: i64, outname: *u8, outpos: *i64) -> i64