News for hackers. Stuff that matters.
Re:Undefined behavior in C is a reading error by vyodaiken on Thursday May 20, 2021 @05:33PM (#27227593)
For your last point, the extent of UB driven changes to semantics is still not widely known in the programmer community. Programmers don't read the standard - they read K&R, and K&R is right now describing a different language. We've had 15 years of programmers repeatedly filing bug reports to be told that the expected, tested, relied on, behavior was ephemeral. Only very sophisticated projects figure out about UB.

Of course compilers have to make assumptions. The debate is (a) over what assumptions it is proper to make and (b) what are the permissible behaviors. The false dichotomy: either do without any optimizations at all or accept whatever UB gives you, is not a useful approach.

Re:Undefined behavior in C is a reading error by MauranKilom on Thursday May 20, 2021 @05:46PM (#27227785)
So what optimizations do you mean with "these UB optimizations" then? And would it change your mind to see a benchmark proving the usefulness of that particular UB optimization?
Re:Undefined behavior in C is a reading error by a1369209993 on Thursday May 20, 2021 @10:14PM (#27229796)
> So what optimizations do you mean with "these UB optimizations" then?

Inferring any propositional statement about the program (eg "this pointer is not null") from the fact that its negation would imply undefined behaviour.

Re:Undefined behavior in C is a reading error by vyodaiken on Thursday May 20, 2021 @06:31PM (#27228259)
e.g. assuming UB can't happen: deleting overflow or null pointer checks, deleting comparisons between pointers that are assumed to point at different objects, ...
Re:Undefined behavior in C is a reading error by Dylan16807 on Thursday May 20, 2021 @11:58PM (#27230350)
I'm surprised you don't think deleting a bunch of checks will improve performance.