http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60229
Bug ID: 60229
Summary: wrong code at -O2 and -O3 on x86_64-linux-gnu
Product: gcc
Version: 4.7.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
The latest gcc 4.7 branch miscompiles the following code on x86_64-linux at -O2
and -O3 in both 32-bit and 64-bit modes.
It also affects 4.6.x, but not 4.8.x and the current gcc trunk.
The issue seems to be considering signed short and signed char for overflows,
but neither overflows.
$ gcc-trunk -O2 small.c
$ a.out
$ gcc-4.8.2 -O2 small.c
$ a.out
$ gcc-4.7.3 -O2 small.c
$ a.out
^C
$ gcc-4.7-branch -O2 small.c
$ a.out
^C
$ gcc-4.7-branch -v
Using built-in specs.
COLLECT_GCC=gcc-4.7-branch
COLLECT_LTO_WRAPPER=/usr/local/gcc47-branch/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.4/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.7/configure --enable-languages=c,c++
Thread model: posix
gcc version 4.7.4 20140209 (prerelease) [gcc-4_7-branch revision 207641] (GCC)
$
-------------------
short a;
int
main()
{
for (; a >= 0; a++)
;
return 0;
}