http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60578
Bug ID: 60578 Summary: wrong code (that hangs) at -O0 on x86_64-linux-gnu (affecting all gcc versions) Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu The current gcc trunk miscompiles the following code on x86_64-linux at -O0 in 64-bit mode (but not 32-bit). It affects all GCC versions and seems to do with wrong integer promotion in the expression "(c ^ 0L) < -1". $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 4.9.0 20140318 (experimental) [trunk revision 208631] (GCC) $ $ gcc-trunk -m32 -O0 small.c $ a.out $ gcc-trunk -m64 -O1 small.c $ a.out $ $ gcc-trunk -m64 -O0 small.c $ a.out ^C $ -------------------------- int a, *b = &a; unsigned c; int foo () { return 0; } int bar () { int i, j, m, n; *b = foo (); for (i = 0; i;) for (; j;) m = 0; if ((c ^ 0L) < -1) return 0; for (; n;) ; return 0; } int main () { bar (); return 0; }