[Bug middle-end/60121] gcc does not warn an obvious out-of-bound array access at -O0 and -O1

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Feb 9 00:47:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60121

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Chengnian Sun from comment #6)
> The test case can be further reduced to the following code, which is NOT
> dead or dependent on bug 60115. 
> 
> int b[1];
> int f() {
>   return b[9999];
> }

Because we don't warn in the front-end.  That was on purpose.  I can find the
old bug reports of why we don't want to warn in the front-end.  The warning
only happens in VPR which is only enabled for -O2 and above (-Os is -O2 plus
optimize for size really).



More information about the Gcc-bugs mailing list