News for hackers. Stuff that matters.
Re:Undefined behavior in C is a reading error by tsimionescu on Thursday May 20, 2021 @05:16PM (#27227395)
> If the value of param is INT_MAX, the behavior of evaluating param + 16 is undefined. It doesn't become defined behavior because a particular implementation makes a particular choice. And the implementation doesn't have to tell you what choice it makes.

The compiler writer argument is as follows:

The program is either UB (when param is INT-MAX - 15 higher) or has exactly 16 iterations. Since we are free to give any semantics to a UB program, it is standard-compliant to always execute 16 times regardless of param's value.

Re:Undefined behavior in C is a reading error by vyodaiken on Friday May 21, 2021 @09:39AM (#27233833)
in which case the overflow will cause the loop to change some random memory, but its ok since removing a single instruction test that is easy to pipeline is worth incorrect results!