logoalt Hacker News

chowellstoday at 2:17 AM3 repliesview on HN

Not only that, the code was wrong. The specification is quite clear that correct programs don't cause UB to be executed at run time. If your wrong code now produces wrong results, that's because it's wrong. That your compiler allowed you to get away with it for decades is a compiler bug, not a feature.

Do I fully believe all of the above? Not exactly. But compiler authors do. Does it make a really good argument to never use C or C++? Yes. If only we had 50 years of optimization work in any language with better semantics.


Replies

saghmtoday at 4:38 AM

Yeah, my slightly more verbose take is that a language that requires you to not ever make any mistakes in order to have a program behave in a predictable way is not a particularly good choice of language if you the ability to pick something else.

JoshTripletttoday at 7:46 AM

The mistake was declaring infinite loops to be UB in the first place.

throwaway786678today at 8:55 AM

> That your compiler allowed you to get away with it for decades is a compiler bug

That UB was added in C++11.

show 1 reply