[Bug c++/52833] -O2 optimizes loop to infinite when loop invariant based on arithmetic overflow

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Apr 2 10:12:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52833

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-04-02 10:12:34 UTC ---
(In reply to comment #0)

> following code is based on artihmetic overflow assumption (after overflow we
> gen <0 number on x86 and x86_64):

Bad assumption, overflow is undefined behaviour.

The bug submission form asys to read http://gcc.gnu.org/bugs/ before reporting
bugs, which says if your code works as you expect with -fwrapv then it's not a
bug in the compiler, it's a bug in your code.



More information about the Gcc-bugs mailing list