Hacker News new | ask | show | jobs
by Mathnerd314 1317 days ago
It's not similar at all. It used to be C operations mapped 1-1 to the hardware, so undefined behavior meant unspecified but well-behaved in the sense that it would not randomly change unrelated registers. Now it means "nasal demons", i.e. the compiler can just ignore any execution path with undefined behavior and eliminate it as dead code.
2 comments

For more, see https://www.complang.tuwien.ac.at/kps2015/proceedings/KPS_20... (clearly distinguishing C* which corresponds to the hardware from "C" which is the subset of C* that excludes all undefined behaviour) and https://arxiv.org/pdf/2201.07845.pdf "How ISO C became unusable for operating systems development".
You’re gonna get the same result each time you compile. But if you change _anything_ the results can be completely different. So, I can agree that it’s not a very useful predictability.