News for hackers. Stuff that matters.
Re:GCC undefined behaviors are getting wild by nwellnhof on Monday November 28, 2022 @06:28AM (#33772296)
> also, even if the compiler didn't utilize UB and kept wrapping integer semantics, the code would still be partly broken were it instead, say, "x * 0x1f0 / 0xffff", as the multiplication could overflow to 0

That's the most important point! You simply cannot detect overflow when multiplying integers in C after the fact. This is not GCC's fault.

I agree that some of the optimizations exploiting UB are too aggressive, but the article presents a really bad example.

There are no comments on this comment yet.