public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/36996] New: Bad optimization
@ 2008-08-01 10:08 nroets at gmail dot com
2008-08-01 11:01 ` [Bug c/36996] " schwab at suse dot de
0 siblings, 1 reply; 3+ messages in thread
From: nroets at gmail dot com @ 2008-08-01 10:08 UTC (permalink / raw)
To: gcc-bugs
When the program below is compiled with -O2, it goes into an endless loop.
#include <stdio.h>
int main (void)
{
int mask;
for (mask = 0; (mask & 7) != 4; mask += 0x55555555) {
printf ("%x\n", mask & 7);
}
}
The output of gcc -v is
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr
--enable-targets=all --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
--
Summary: Bad optimization
Product: gcc
Version: 4.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nroets at gmail dot com
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36996
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/36996] Bad optimization
2008-08-01 10:08 [Bug c/36996] New: Bad optimization nroets at gmail dot com
@ 2008-08-01 11:01 ` schwab at suse dot de
0 siblings, 0 replies; 3+ messages in thread
From: schwab at suse dot de @ 2008-08-01 11:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from schwab at suse dot de 2008-08-01 10:59 -------
This depends on undefined behaviour when mask + 0x55555555 overflows. Change
mask to unsigned to get defined behaviour.
--
schwab at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36996
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/36996] Bad optimization
[not found] <bug-36996-4@http.gcc.gnu.org/bugzilla/>
@ 2013-03-21 9:59 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-03-21 9:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36996
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> 2013-03-21 09:59:24 UTC ---
*** Bug 56672 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-21 9:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-01 10:08 [Bug c/36996] New: Bad optimization nroets at gmail dot com
2008-08-01 11:01 ` [Bug c/36996] " schwab at suse dot de
[not found] <bug-36996-4@http.gcc.gnu.org/bugzilla/>
2013-03-21 9:59 ` rguenth at gcc dot gnu.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).