https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78170
Bug ID: 78170 Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu 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 is a regression from 6.2.x. $ 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.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 7.0.0 20161031 (experimental) [trunk revision 241694] (GCC) $ $ gcc-trunk -Os small.c; ./a.out 0 $ gcc-6.2 -O2 small.c; ./a.out 0 $ $ gcc-trunk -O2 small.c; ./a.out -1 $ --------------------------------------------------------- int printf (const char *, ...); int a, b, d; struct S0 { int f0; int f1; int f2; int f3; int f4; int f5:15; int f6:17; int f7:2; int f8:30; } c; void fn1 () { d = b = 1; for (; b; b = a) { struct S0 e = { 0, 0, 0, 0, 0, 0, 1, 0, 1 }; c = e; c.f6 = -1; } } int main () { fn1 (); printf ("%d\n", c.f7); return 0; }