lib/ww/lex: port the u64 overflow guard into parseint (#53)
wwstage parseint dropped the pre-multiply overflow guard the C twin carries (cmd/wcc/lex.c:156, if (v > (u64)~0ULL / (u64)base)), so any integer literal exceeding u64 was silently accepted mod 2^64 while cstage loudly rejected with 'bad integer literal' — a rule-10 stage divergence and a silent wrong constant. Port the guard before the multiply-add; wwstage now rejects in lockstep with cstage. lib/ww embeds into the w6c/wwdump combined.ww snapshots; both regen'd. 989_intoverflow_reject pins the reject-matrix on both driver twins.
This commit is contained in:
@@ -6985,6 +6985,7 @@ fn parseint(p: *u8, n: u64, base: i32, ok: *bool) u64 = {
|
||||
};
|
||||
if (d < 0) { *ok = false; return 0u64; };
|
||||
if (d >= base) { *ok = false; return 0u64; };
|
||||
if (v > ~0u64 / (base: u64)) { *ok = false; return 0u64; };
|
||||
v = v * (base: u64) + (d: u64);
|
||||
got = true;
|
||||
i += 1u64;
|
||||
|
||||
Reference in New Issue
Block a user