https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68911
Bug ID: 68911 Summary: wrong code at -Os and above on x86-64-linux-gnu (in 32- and 64-bit modes) Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: chengniansun at gmail dot com Target Milestone: --- The current gcc trunk miscompiles the following code on x86_64-linux-gnu in both 32- and 64-bit modes at -Os and above. $: 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 20151214 (experimental) [trunk revision 231607] (GCC) $: $: gcc-trunk -Os -w -m32 small.c ; timeout -s 9 10 ./a.out Killed $: gcc-trunk -O2 -w -m32 small.c ; timeout -s 9 10 ./a.out Killed $: gcc-trunk -O3 -w -m32 small.c ; timeout -s 9 10 ./a.out Killed $: gcc-trunk -O0 -w -m32 small.c ; timeout -s 9 10 ./a.out $: gcc-trunk -O1 -w -m32 small.c ; timeout -s 9 10 ./a.out $: $: gcc-trunk -Os -w -m64 small.c ; timeout -s 9 10 ./a.out Killed $: gcc-trunk -O2 -w -m64 small.c ; timeout -s 9 10 ./a.out Killed $: gcc-trunk -O3 -w -m64 small.c ; timeout -s 9 10 ./a.out Killed $: $: cat small.c char a; int b, c; short d; int main() { unsigned e = 2; for (; c < 2; c++) { int f = ~e / 7; if (f) a = e = ~(b && d); while (e < 94) e++; } return 0; } $: