[Bug tree-optimization/86691] New: missing -Warray-bounds due to early folding of out-of-bounds accesses
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jul 26 21:21:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86691
Bug ID: 86691
Summary: missing -Warray-bounds due to early folding of
out-of-bounds accesses
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
GCC folds early on the third operand of the conditional into zero causing
-Warray-bounds not to trigger.
$ cat d.c && gcc -O2 -S -Wall -Warray-bounds=2 -fdump-tree-gimple=/dev/stdout
d.c
const char a[2][3] = { "12", "123" };
int g (int i)
{
return i ? a[0][0] : a[7][9];
}
g (int i)
{
int D.1902;
int iftmp.0;
if (i != 0) goto <D.1904>; else goto <D.1905>;
<D.1904>:
_1 = 49;
iftmp.0 = (int) _1;
goto <D.1906>;
<D.1905>:
_2 = 0;
iftmp.0 = (int) _2;
<D.1906>:
D.1902 = iftmp.0;
return D.1902;
}
More information about the Gcc-bugs
mailing list