https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80549
Bug ID: 80549 Summary: wrong code at -O2 and -O3 in both 32-bit and 64-bit modes on x86_64-linux-gnu (executable does not terminate) Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: chengniansun at gmail dot com Target Milestone: --- $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk --disable-bootstrap Thread model: posix gcc version 8.0.0 20170424 (experimental) [trunk revision 247088] (GCC) $ gcc-trunk -O2 small.c ; timeout -s 9 10 ./a.out Killed $ cat small.c char a, b; int c; short d; void fn1(int p1) { short e = 4; int f; d = 0; for (; d <= 0; d++) e = 0; if (e) goto L1; L2: if (p1) { a = 9; for (; a; ++a) { f = 5; for (; f != 32; ++f) c = 8; L1: if (b) goto L2; } } } int main() { fn1(1); return 0; } $ $