[Bug tree-optimization/59932] New: spurious undefined behavior warning on valid code
su at cs dot ucdavis.edu
gcc-bugzilla@gcc.gnu.org
Fri Jan 24 03:09:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59932
Bug ID: 59932
Summary: spurious undefined behavior warning on valid code
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: su at cs dot ucdavis.edu
The current gcc trunk issues a spurious undefined behavior warning when
compiling the following valid code at -Os and above in both 32-bit and 64-bit
mode.
It does not affect gcc 4.8 though, so it is a regression from 4.8.x.
Interestingly, the code also causes clang (from 3.2 to its current trunk) to
hang 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-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-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 4.9.0 20140123 (experimental) [trunk revision 206958] (GCC)
$
$ gcc-trunk -O1 small.c; a.out
$ gcc-4.8.2 -Os small.c; a.out
$
$ gcc-trunk -Os small.c
small.c: In function ‘main’:
small.c:27:16: warning: iteration 2147483646u invokes undefined behavior
[-Waggressive-loop-optimizations]
for (; p1; p1++)
^
small.c:27:3: note: containing loop
for (; p1; p1++)
^
$
$ timeout -s 9 30 clang-trunk -Os small.c
Killed
$
$
---------------------------------------
int a, b, c, e[1], f, g, h, i, k, m, n;
short j;
struct
{
short f1;
} d;
static int
fn1 (int p1)
{
int l = 64696;
for (f = 0; f != 1; f--)
{
if (d.f1 > l)
{
h = p1;
if (!h)
l = 0;
}
else
return b;
for (; a; a++)
if (e[a])
break;
}
for (; p1; p1++)
{
if (h)
continue;
if (l)
i = j = k = g && d.f1 != p1;
for (; h != 1; h++)
;
}
return 0;
}
int
main ()
{
m = c = 1;
n = fn1 (c);
return 0;
}
More information about the Gcc-bugs
mailing list