Comment by vlovich123
5 months ago
In hot paths it can be even more. This is why even Rust defines it as wrapping but elides the overflow panic in release builds.
5 months ago
In hot paths it can be even more. This is why even Rust defines it as wrapping but elides the overflow panic in release builds.
It is defined as an error. That error’s default handling is wrapping when debug_assertions is off, and panic when it’s on, but since it’s an incorrect program (though not UB) either behavior is acceptable in any mode.
If it is defined as an error, but the compiled build will continue to run with the value wrapped around, I would say that's indistinguishable from UB.
No. An integer getting deterministically set to an unintended value is a bug. A bug is not the same thing as UB. (Even if it were non-deterministic, it would still not be anything like UB.) It's not the same ballpark, not even the same sport.
5 replies →
It's indistinguishable from unspecified behavior, not from undefined behavior. Unspecified behavior has to pick from a finite list of allowed behaviors. Undefined behavior can do anything.
15 replies →
Yeah on average. On some paths it's almost free