This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/60121] gcc does not warn an obvious out-of-bound array access at -O0 and -O1
- From: "chengniansun at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 09 Feb 2014 01:27:38 +0000
- Subject: [Bug middle-end/60121] gcc does not warn an obvious out-of-bound array access at -O0 and -O1
- Auto-submitted: auto-generated
- References: <bug-60121-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60121
--- Comment #8 from Chengnian Sun <chengniansun at gmail dot com> ---
(In reply to Andrew Pinski from comment #7)
> (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).
Thanks. Is it possible to enable vrp with -ftree-vrp at -O0 level? Therefore
the user can get this warning even when the code is not optimized?