Integer arithmetic is unchecked: silent wrong results in release, panics in debug #22
Labels
No labels
automated-🤖
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Hemera/nomo#22
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
NomoValue::try_add/try_sub/try_mul/try_div(src/value.rs:116-225) perform rawu64/i64arithmetic with no checked semantics.debugbuilds this panics (e.g.attempt to subtract with overflow).releasebuilds it silently wraps to a wrong value.Verified:
{{= 1 - 2 }}→ release: wraps to a hugeu64instead of erroring.{{= 18446744073709551615 + 1 }}→ release: wraps to0.{{= 1 / 0 }}→ division by zero.Since integer literals are
u64and signed values can arrive from context (serde_jsoni64), this is reachable with ordinary data. Consider returning anEvaluationErroron overflow/division-by-zero (or usingchecked_*), so both debug and release behave the same.rendernamerendername