logoalt Hacker News

saghmyesterday at 4:52 PM3 repliesview on HN

I guess given that it was UB before, the compiler was already allowed to put a system call here if it wanted for some reason


Replies

chowellstoday at 2:17 AM

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.

show 3 replies
fc417fc802yesterday at 9:44 PM

Yes, it was a horrible situation that has been replaced by an only slightly less horrible situation.

show 1 reply
cryptonectortoday at 4:53 AM

Yes, but now it has to. I guess that's better? than UB, maybe.