http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58731
Bug ID: 58731 Summary: wrong code (hangs) at -O3 on x86_64-linux-gnu Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu The current gcc trunk and gcc 4.8 produce wrong code that hangs for the following testcase on x86_64-linux when compiled at -O3 (in both 32-bit and 64-bit modes). This is a regression from 4.7.x. The testcase also triggers a different issue at -O2: a spurious "undefined behavior" warning (see below). $ 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 --enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror --enable-checking=release --with-gmp=/usr/local/gcc-trunk --with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk --with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk Thread model: posix gcc version 4.9.0 20131014 (experimental) [trunk revision 203572] (GCC) $ $ gcc-trunk -O2 small.c; a.out small.c: In function ‘main’: cc1: warning: iteration 5u invokes undefined behavior [-Waggressive-loop-optimizations] small.c:6:3: note: containing loop for (b = 4; b > -30; b--) ^ $ $ gcc-trunk -Os small.c; a.out $ $ gcc-trunk -O3 small.c; a.out ^C $ gcc-4.8 -O3 small.c; a.out ^C $ $ gcc-4.7 -O3 small.c; a.out $ ---------------------------------- int a, b, c, d, e; int main () { for (b = 4; b > -30; b--) for (; c;) for (;;) { e = a > 2147483647 - b; if (d) break; } return 0; }