News for hackers. Stuff that matters.
Re:The Value of Undefined Behavior by steveklabnik on Saturday July 21, 2018 @06:01PM (#17584079)
The parent spoke a bit too broadly. Here’s the rules:

* overflow is a “program error”, not UB

* compilers must either check for overflow and panic, or two’s compliment wrap

* when debug_assertions are on, implementations are required to panic on overflow

This means release mode wraps today, but if it’s cheap enough someday, we could make it panic.

If you want specific semantics on overflow, then you should use the various wrappers and/or methods that let you do them directly, rather than relying on any of the above. But you don’t have to specify; by default, the above is the semantics.

Re:The Value of Undefined Behavior by Paul-ish on Saturday July 21, 2018 @08:12PM (#17584567)
What if rust got "unchecked" (unsafe) versions of arithmetic operations that have C arithmetic semantics. Kind of the opposite of "checked_add".
Re:The Value of Undefined Behavior by steveklabnik on Sunday July 22, 2018 @04:17AM (#17585811)
It’s possible! Nobody has ever proposed it...