* [Bug middle-end/60121] gcc does not warn an obvious out-of-bound array access at -O0 and -O1
2014-02-08 23:15 [Bug c/60121] New: gcc does not warn an obvious out-of-bound array access at -O0 and -O1 su at cs dot ucdavis.edu
@ 2014-02-08 23:41 ` pinskia at gcc dot gnu.org
2014-02-09 0:08 ` su at cs dot ucdavis.edu
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-02-08 23:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60121
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |middle-end
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this is expected. out of bounds warnings come not from the front-end
but the middle-end and are designed not to warn about in dead code. This code
is dead as a != 0 is always false.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/60121] gcc does not warn an obvious out-of-bound array access at -O0 and -O1
2014-02-08 23:15 [Bug c/60121] New: gcc does not warn an obvious out-of-bound array access at -O0 and -O1 su at cs dot ucdavis.edu
2014-02-08 23:41 ` [Bug middle-end/60121] " pinskia at gcc dot gnu.org
@ 2014-02-09 0:08 ` su at cs dot ucdavis.edu
2014-02-09 0:14 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-02-09 0:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60121
--- Comment #3 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Andrew Pinski from comment #2)
> I think this is expected. out of bounds warnings come not from the front-end
> but the middle-end and are designed not to warn about in dead code. This
> code is dead as a != 0 is always false.
Andrew, it's actually the complete opposite with this testcase.
At -O0 and -O1, gcc unlikely knows that the out-of-bound array access is dead,
so the warning should be issued, but it's not.
On the other hand, at -Os and above, gcc likely knows that the out-of-bound
array access is dead, but it warns.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/60121] gcc does not warn an obvious out-of-bound array access at -O0 and -O1
2014-02-08 23:15 [Bug c/60121] New: gcc does not warn an obvious out-of-bound array access at -O0 and -O1 su at cs dot ucdavis.edu
2014-02-08 23:41 ` [Bug middle-end/60121] " pinskia at gcc dot gnu.org
2014-02-09 0:08 ` su at cs dot ucdavis.edu
@ 2014-02-09 0:14 ` pinskia at gcc dot gnu.org
2014-02-09 0:18 ` su at cs dot ucdavis.edu
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-02-09 0:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60121
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually the reason for the warning is due to LIM pulling the out of bounds
access out of the loop, the same reason why bug 60115 fails. It is just
showing the bug a different way.
*** This bug has been marked as a duplicate of bug 60115 ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/60121] gcc does not warn an obvious out-of-bound array access at -O0 and -O1
2014-02-08 23:15 [Bug c/60121] New: gcc does not warn an obvious out-of-bound array access at -O0 and -O1 su at cs dot ucdavis.edu
` (2 preceding siblings ...)
2014-02-09 0:14 ` pinskia at gcc dot gnu.org
@ 2014-02-09 0:18 ` su at cs dot ucdavis.edu
2014-02-09 0:32 ` chengniansun at gmail dot com
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-02-09 0:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60121
--- Comment #5 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Andrew Pinski from comment #4)
> Actually the reason for the warning is due to LIM pulling the out of bounds
> access out of the loop, the same reason why bug 60115 fails. It is just
> showing the bug a different way.
>
> *** This bug has been marked as a duplicate of bug 60115 ***
Andrew, you completely lost me ...
Please note that this warning issue affects ALL earlier versions of GCC too,
but 60115 only for the current 4.8 branch and the main trunk.
Please check the report carefully. Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/60121] gcc does not warn an obvious out-of-bound array access at -O0 and -O1
2014-02-08 23:15 [Bug c/60121] New: gcc does not warn an obvious out-of-bound array access at -O0 and -O1 su at cs dot ucdavis.edu
` (3 preceding siblings ...)
2014-02-09 0:18 ` su at cs dot ucdavis.edu
@ 2014-02-09 0:32 ` chengniansun at gmail dot com
2014-02-09 0:47 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: chengniansun at gmail dot com @ 2014-02-09 0:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60121
--- Comment #6 from Chengnian Sun <chengniansun at gmail dot com> ---
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];
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/60121] gcc does not warn an obvious out-of-bound array access at -O0 and -O1
2014-02-08 23:15 [Bug c/60121] New: gcc does not warn an obvious out-of-bound array access at -O0 and -O1 su at cs dot ucdavis.edu
` (4 preceding siblings ...)
2014-02-09 0:32 ` chengniansun at gmail dot com
@ 2014-02-09 0:47 ` pinskia at gcc dot gnu.org
2014-02-09 1:27 ` chengniansun at gmail dot com
2014-02-09 6:39 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-02-09 0:47 UTC (permalink / raw)
To: gcc-bugs
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).
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/60121] gcc does not warn an obvious out-of-bound array access at -O0 and -O1
2014-02-08 23:15 [Bug c/60121] New: gcc does not warn an obvious out-of-bound array access at -O0 and -O1 su at cs dot ucdavis.edu
` (5 preceding siblings ...)
2014-02-09 0:47 ` pinskia at gcc dot gnu.org
@ 2014-02-09 1:27 ` chengniansun at gmail dot com
2014-02-09 6:39 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: chengniansun at gmail dot com @ 2014-02-09 1:27 UTC (permalink / raw)
To: gcc-bugs
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?
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/60121] gcc does not warn an obvious out-of-bound array access at -O0 and -O1
2014-02-08 23:15 [Bug c/60121] New: gcc does not warn an obvious out-of-bound array access at -O0 and -O1 su at cs dot ucdavis.edu
` (6 preceding siblings ...)
2014-02-09 1:27 ` chengniansun at gmail dot com
@ 2014-02-09 6:39 ` jakub at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-02-09 6:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60121
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
No. VRP isn't really a cheap pass and for -O0 the most important thing is
compile time speed. GCC has never guaranteed the same warnings between
optimization levels, for frontend warnings it is sometimes possible to have the
same warnings, but for middle-end warnings it is not possible and never a goal.
Think say about uninitialized warnings, some of them heavily depend on which
functions are inlined and which are not.
^ permalink raw reply [flat|nested] 9+ messages in thread