You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Signed PHIR register size of usize::MAX overflows the width check (debug panic, release accepts) #1341
In a debug build of pecos_rslib, this panics: attempt to add with overflow at crates/pecos-phir-json/src/v0_1/environment.rs:617 (#1314 branch).
Cause
Environment::validate_variable_size (crates/pecos-phir-json/src/v0_1/environment.rs, ~589 on dev) computes needed = size + 1 for signed types. For size == usize::MAX:
debug builds panic;
release builds (including the Python wheel) wrap needed to 0, so the check passes and the declaration is accepted, although the size cannot fit any backing type.
The Python interpreter rejects the same declaration, since Python integers do not overflow, so the paths disagree.
Direction
Use size.checked_add(1) and treat None as "does not fit". The existing "use at most N bits" error then covers it. Add a test with size: usize::MAX for a signed type on native, the Rust interpreter and the JSON-to-module converter.
Activity