News for hackers. Stuff that matters.
Re:Impact of Undefined Behavior on Performance by vkazanov on Friday July 09, 2021 @02:40AM (#27781033)
So, in a narrow, simplistic case signed integer overflow undef behaviour made it possible to replace a loop with a constant. Hooooray!

Pretending that integer overflows don't happen because of undef behaviour is... Funny. Integer overflow do happen a lot, both with signed and unsigned ints. Compilers should only apply radical optimisations in this situation if they can prove an overflow will never happen. Otherwise, they should not touch the loop.

EDIT: typos, rephrasing for clarity

Re:Impact of Undefined Behavior on Performance by cobbal on Friday July 09, 2021 @03:10AM (#27781185)
The problem is that “radical” is in the eye of the beholder. If a language is so poorly specified that developers and the specification don’t agree on the meaning of a program, that leaves optimizers in an unwinnable situation.
Re:Impact of Undefined Behavior on Performance by vkazanov on Friday July 09, 2021 @03:28AM (#27781284)
In this particular case the problem can relatively painfully defined away by Wg14.