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.
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.