https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79286
Bug ID: 79286 Summary: wrong code at -O3 on x86_64-linux-gnu in 32-bit mode (but not in 64-bit mode) Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu Target Milestone: --- This seems to be a recent regression. $ 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/7.0.1/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 7.0.1 20170130 (experimental) [trunk revision 245020] (GCC) $ $ gcc-trunk -m32 -O2 small.c; ./a.out $ gcc-trunk -m64 -O3 small.c; ./a.out $ $ gcc-trunk -m32 -O3 small.c $ ./a.out Segmentation fault (core dumped) $ --------------------------------------------- int printf (const char *, ...); int a[6], b, c, d, e, f, g, h; static int i[][8] = { { 0 } }; void fn1 (int l) { c = (c & 5) ^ a[(c ^ l) & 5]; } void fn2 () { fn1 (e >> 5); fn1 (e >> 6 & 5); c = (c & 5) ^ a[(c ^ 5) & 5]; fn1 (e >> 2 & 5); fn1 (e & 5); fn1 (e >> 28 & 5); } void fn3 () { int k; for (; g < 4; g++) { while (d) { fn2 (); if (k) printf ("%d\n", k); } while (f) while (h++) k = i[300000000000000000][0]; while (b) while (1) d++; } } int main () { fn3 (); return 0; }