[Bug tree-optimization/72817] New: wrong code at -O3 on x86_64-linux-gnu (in both 32-bit and 64-bit modes)
su at cs dot ucdavis.edu
gcc-bugzilla@gcc.gnu.org
Fri Aug 5 15:09:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72817
Bug ID: 72817
Summary: wrong code at -O3 on x86_64-linux-gnu (in both 32-bit
and 64-bit modes)
Product: gcc
Version: 7.0
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: ---
At -O3, the generated code hangs. At -O2, although the generated code does not
hang, there is a spurious warning of invoking undefined behavior.
This should be a very recent regression as r238938 does not yet miscompile the
code.
$ 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 20160805 (experimental) [trunk revision 239166] (GCC)
$
$ gcc-trunk -Os small.c; ./a.out
$ gcc-6.1 -O3 small.c; ./a.out
$
$ /usr/local/gcc-r238938/bin/gcc -O3 small.c; ./a.out
$
$ gcc-trunk -O2 small.c
small.c: In function ‘main’:
small.c:6:26: warning: iteration 26 invokes undefined behavior
[-Waggressive-loop-optimizations]
for (a = 3; a != -1; a -= 5)
^~
small.c:6:3: note: within this loop
for (a = 3; a != -1; a -= 5)
^~~
$ ./a.out
$
$ gcc-trunk -O3 small.c
$ timeout -s 9 10 ./a.out
Killed
$
--------------------------------
char a;
short b;
int main ()
{
for (a = 3; a != -1; a -= 5)
while (b)
;
return 0;
}
More information about the Gcc-bugs
mailing list