This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/31083] for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly.
- From: "manu at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Mar 2007 14:38:47 -0000
- Subject: [Bug c/31083] for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly.
- References: <bug-31083-14210@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from manu at gcc dot gnu dot org 2007-03-08 14:38 -------
I think you are relying on the fact that signed overflow wraps, when in
standard C it is actually undefined (it may wrap, it may not). To make integers
wrap on overflow you use unsigned or -fwrapv.
Thus, I think this is a duplicate of PR 30475.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31083