logoalt Hacker News

aw1621107today at 10:58 AM0 repliesview on HN

> Rust's signed arithmetic is fully specified to wrap around.

Well, kind of. It's currently documented to wrap in release mode by default, but it's just that - a default. You're free to enable overflow checks in release mode (or disable them in debug if you really like oddball configurations), and either way overflow is considered a logic error that devs shouldn't rely on (and basically can't rely on when not in control of the end binary since it's the end user who controls overflow checks).

The Rust devs are theoretically open to making signed overflow panic by default, but consider such a change unlikely unless "something materially changes" [0].

[0]: https://github.com/rust-lang/rust/issues/47739#issuecomment-...