public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/31083] New: for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly.
@ 2007-03-08 14:17 niklas at cadence dot com
2007-03-08 14:18 ` [Bug c/31083] " niklas at cadence dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: niklas at cadence dot com @ 2007-03-08 14:17 UTC (permalink / raw)
To: gcc-bugs
The following code hangs for -O2 or -O3. I am running on a 32-bit machine, and
with -O1 it terminates after a few seconds:
for (int i = 1; i != 0; i++);
You can replace 'i = 1' with 'i = (1<<30)' for faster testing.
I am running Gentoo Linux 64-bit. 'gcc --version' says: gcc (GCC) 4.1.1 (Gentoo
4.1.1).
--
Summary: for (int i = 1; i != 0; i++); hangs for 32-bit ints with
-O2 or above. Should wrap quickly.
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: niklas at cadence dot com
GCC build triplet: What is this? How about an explanation in "bug writing
guideline
GCC host triplet: What is this? How about an explanation in "bug writing
guideline
GCC target triplet: What is this? How about an explanation in "bug writing
guideline
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31083
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/31083] for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly.
2007-03-08 14:17 [Bug c/31083] New: for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly niklas at cadence dot com
@ 2007-03-08 14:18 ` niklas at cadence dot com
2007-03-08 14:38 ` manu at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: niklas at cadence dot com @ 2007-03-08 14:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from niklas at cadence dot com 2007-03-08 14:17 -------
I am running on a 64-bit machine, not 32-bit as stated in the first line. Typo,
sorry.
--
niklas at cadence dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |niklas at cadence dot com
Keywords| |wrong-code
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31083
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/31083] for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly.
2007-03-08 14:17 [Bug c/31083] New: for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly niklas at cadence dot com
2007-03-08 14:18 ` [Bug c/31083] " niklas at cadence dot com
@ 2007-03-08 14:38 ` manu at gcc dot gnu dot org
2007-03-08 14:41 ` manu at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-03-08 14:38 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/31083] for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly.
2007-03-08 14:17 [Bug c/31083] New: for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly niklas at cadence dot com
2007-03-08 14:18 ` [Bug c/31083] " niklas at cadence dot com
2007-03-08 14:38 ` manu at gcc dot gnu dot org
@ 2007-03-08 14:41 ` manu at gcc dot gnu dot org
2007-03-08 15:33 ` rguenth at gcc dot gnu dot org
2007-03-09 0:51 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-03-08 14:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from manu at gcc dot gnu dot org 2007-03-08 14:41 -------
*** Bug 31082 has been marked as a duplicate of this bug. ***
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31083
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/31083] for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly.
2007-03-08 14:17 [Bug c/31083] New: for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly niklas at cadence dot com
` (2 preceding siblings ...)
2007-03-08 14:41 ` manu at gcc dot gnu dot org
@ 2007-03-08 15:33 ` rguenth at gcc dot gnu dot org
2007-03-09 0:51 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-03-08 15:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2007-03-08 15:33 -------
Integer overflow is undefined.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31083
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/31083] for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly.
2007-03-08 14:17 [Bug c/31083] New: for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly niklas at cadence dot com
` (3 preceding siblings ...)
2007-03-08 15:33 ` rguenth at gcc dot gnu dot org
@ 2007-03-09 0:51 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-09 0:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pinskia at gcc dot gnu dot org 2007-03-09 00:50 -------
In reference to the triplets question, refer next time to
http://gcc.gnu.org/bugs.html
Which tells you how to file a bug report.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31083
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-03-09 0:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-08 14:17 [Bug c/31083] New: for (int i = 1; i != 0; i++); hangs for 32-bit ints with -O2 or above. Should wrap quickly niklas at cadence dot com
2007-03-08 14:18 ` [Bug c/31083] " niklas at cadence dot com
2007-03-08 14:38 ` manu at gcc dot gnu dot org
2007-03-08 14:41 ` manu at gcc dot gnu dot org
2007-03-08 15:33 ` rguenth at gcc dot gnu dot org
2007-03-09 0:51 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).