https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69595
Bug ID: 69595
Summary: [6 Regression] Bogus -Warray-bound warning due to
missed optimization
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Keywords: diagnostic, missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: rguenth at gcc dot gnu.org
Target Milestone: ---
char *y;
void foo (int sysnum)
{
static char *x[] = {};
int nsyscalls = sizeof x / sizeof x[0];
if (sysnum < 0 || sysnum >= nsyscalls)
return;
else
y = x[sysnum];
}
warns at -O2 -Warray-bounds because we don't optimize sysnum < 0 || sysnum >= 0
to true before VRP1. We optimize this only in reassoc.
VRP warns as 'sysnum' in the x[sysnum] path is UNDEFINED.