https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69322
Bug ID: 69322 Summary: wrong code at -O3 on x86-64-linux-gnu (in 32- and 64-bit modes) Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: chengniansun at gmail dot com Target Milestone: --- The following code is miscompiled by the gcc trunk at -O3 in both 32-bit and 32-bit modes on x86_64-linux-gnu. $: 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/6.0.0/lto-wrapper Target: x86_64-pc-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 6.0.0 20160116 (experimental) [trunk revision 232466] (GCC) $: $: $: gcc-trunk small.c -O3 -m32 ; ./a.out g_620=0 $: gcc-trunk small.c -O3 -m64 ; ./a.out g_620=0 $: gcc-trunk small.c -O0 ; ./a.out g_620=1 $: $: cat small.c int printf(const char*, ...); int a; char b, d; short c; short fn1(int p1, int p2) { return p2 >= 2 ? p1 : p1 > p2; } int main() { int *e = &a, *f = &a; b = 1; for (; b <= 9; b++) { c = *e != 5 || d; *f = fn1(c || b, a); } printf("g_620=%lld\n", (long long)a); return 0; } $: