News for hackers. Stuff that matters.
Re:Impact of Undefined Behavior on Performance by pornel on Friday July 09, 2021 @05:52AM (#27782066)
Quality/performance of optimizations may change, but that's separate from UB.

Behavior of the code is not supposed to ever change, unless you let the program to cause UB (e.g. give it numbers that do overflow). But you're not allowed to let the program cause UB under any circumstances, ever. So as far as "correct" programs go, it's guaranteed not to change.

UB is about giving freedom to the compiler to assume that certain cases never ever happen, so it doesn't need to worry about them. In C, C++, and unsafe Rust the programmer has responsibility to ensure that UB situations can't happen, so the effect of the assumption can't be observed.

There are no comments on this comment yet.