mirror of
https://github.com/fluffos/fluffos
synced 2026-08-12 18:26:06 -04:00
'<<'/'>>' with a shift count that's negative or >= 64 is UB for LPC's 64-bit int. Previously fixed by rejecting the count with a clean error(); switched instead to masking the count to its low 6 bits (`& 63`) before shifting, matching Java's `long` shift semantics (JLS 15.19). This keeps every LPC int a legal shift count with a deterministic result (e.g. `1 << 100` == `1 << 36`) rather than making an otherwise-ordinary script error out for shifting by a large or negative amount. Applied consistently across all three parallel sites so a folded and unfolded shift by the same count always agree: the runtime efuns (f_lsh/f_rsh/f_lsh_eq/f_rsh_eq, ops.cc), the compile-time constant folder (trees.cc's binary_int_op()), and the #if preprocessor evaluator (lexer_rules_pp.cc's ifexpr_binop()). Updated shift_overflow.lpc to assert the masked values instead of a caught error, and AGENTS.md's audit-checklist entry to describe masking rather than guard-and-error for shifts specifically (the INT_MIN/-1 divide/modulo guards are unchanged). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YTPLudxra3u1andNyWJEQG |
||
|---|---|---|
| .. | ||
| buffer_bytes.lpc | ||
| buffer_range_assign.lpc | ||
| class.lpc | ||
| compound_assign_float.lpc | ||
| compound_assign_undefined.lpc | ||
| foreach.lpc | ||
| mapping.lpc | ||
| range.lpc | ||
| ref.lpc | ||
| shift_overflow.lpc | ||
| string_char_incdec_value.lpc | ||
| string_char_lvalue_ref_reentrancy.lpc | ||
| string_index.lpc | ||
| switch.lpc | ||
| too_deep_recursion.lpc | ||