Hacker News new | ask | show | jobs
by steveklabnik 3275 days ago
Some additional points:

* It's not UB in Rust, it's guaranteed to be two's compliment overflow.

* It's still a "program error" and debug builds are required to panic.

* Non-debug builds are allowed to either panic or do the overflow, for performance reasons, as you mention. If it was feasible to always panic we'd do that; the current wording allows us to change it to do so in the future if it becomes feasible.

* If you want to do a checked add, you can, it's just not the default.