public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57367] New: Missing warning: array subscript is above array bounds
@ 2013-05-22 10:51 Gildos at gmail dot com
2013-05-22 11:09 ` [Bug c++/57367] " glisse at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Gildos at gmail dot com @ 2013-05-22 10:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57367
Bug ID: 57367
Summary: Missing warning: array subscript is above array bounds
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Gildos at gmail dot com
I write this simple code in the file test.cpp:
#####
#include <stdio.h>
int main(int argc, char**argv)
{
(void)argv;
int pippo[100] ;
pippo[1000] = 1 ;
pippo[0] = pippo[0] ;
return argc;
}
#####
I receive NO warning typing:
$ gcc -Wall test.cpp -o test
Thanks
Guido
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/57367] Missing warning: array subscript is above array bounds
2013-05-22 10:51 [Bug c++/57367] New: Missing warning: array subscript is above array bounds Gildos at gmail dot com
@ 2013-05-22 11:09 ` glisse at gcc dot gnu.org
2013-05-22 11:38 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-05-22 11:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57367
--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
This is all dead code, gcc discards it before it looks at possible issues.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/57367] Missing warning: array subscript is above array bounds
2013-05-22 10:51 [Bug c++/57367] New: Missing warning: array subscript is above array bounds Gildos at gmail dot com
2013-05-22 11:09 ` [Bug c++/57367] " glisse at gcc dot gnu.org
@ 2013-05-22 11:38 ` rguenth at gcc dot gnu.org
2013-05-22 11:54 ` paolo.carlini at oracle dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-05-22 11:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57367
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2013-05-22
Ever confirmed|0 |1
Severity|normal |enhancement
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed as a frontend issue. Nobody bothered to implement the trivial
cases there.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/57367] Missing warning: array subscript is above array bounds
2013-05-22 10:51 [Bug c++/57367] New: Missing warning: array subscript is above array bounds Gildos at gmail dot com
2013-05-22 11:09 ` [Bug c++/57367] " glisse at gcc dot gnu.org
2013-05-22 11:38 ` rguenth at gcc dot gnu.org
@ 2013-05-22 11:54 ` paolo.carlini at oracle dot com
2013-05-22 12:24 ` Gildos at gmail dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-22 11:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57367
--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Yeah, shared between the front-ends, this isn't a C++-only issue, of course.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/57367] Missing warning: array subscript is above array bounds
2013-05-22 10:51 [Bug c++/57367] New: Missing warning: array subscript is above array bounds Gildos at gmail dot com
` (2 preceding siblings ...)
2013-05-22 11:54 ` paolo.carlini at oracle dot com
@ 2013-05-22 12:24 ` Gildos at gmail dot com
2013-05-22 12:33 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Gildos at gmail dot com @ 2013-05-22 12:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57367
--- Comment #4 from Guido Del Sarto <Gildos at gmail dot com> ---
I do not receive warnings with the following (no dead code).
#####
#include <stdio.h>
void warning( int pippo[100] )
{
pippo[1000] += pippo[0];
printf( "%d\n", pippo[1000] ) ;
}
int main(int argc, char**argv)
{
(void)argv;
int pippo[100] ;
pippo[ 0] = 0 ;
pippo[1000] = 1 ;
warning(pippo);
return argc ;
}
#####
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/57367] Missing warning: array subscript is above array bounds
2013-05-22 10:51 [Bug c++/57367] New: Missing warning: array subscript is above array bounds Gildos at gmail dot com
` (3 preceding siblings ...)
2013-05-22 12:24 ` Gildos at gmail dot com
@ 2013-05-22 12:33 ` paolo.carlini at oracle dot com
2013-05-22 12:50 ` paolo.carlini at oracle dot com
2013-05-22 12:59 ` rguenth at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-22 12:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57367
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Remember that -O2 is required for this kind of middle-end check. A front-end
check would not.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/57367] Missing warning: array subscript is above array bounds
2013-05-22 10:51 [Bug c++/57367] New: Missing warning: array subscript is above array bounds Gildos at gmail dot com
` (4 preceding siblings ...)
2013-05-22 12:33 ` paolo.carlini at oracle dot com
@ 2013-05-22 12:50 ` paolo.carlini at oracle dot com
2013-05-22 12:59 ` rguenth at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-22 12:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57367
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu.org
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Disappointing, Richard, that in 4.8/4.9 (vs 4.7) we don't seem to warn at all
for the testcase in Comment#4 too. I'm wondering if the tree-vrp.c check
couldn't be done a bit earlier, I don't know.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/57367] Missing warning: array subscript is above array bounds
2013-05-22 10:51 [Bug c++/57367] New: Missing warning: array subscript is above array bounds Gildos at gmail dot com
` (5 preceding siblings ...)
2013-05-22 12:50 ` paolo.carlini at oracle dot com
@ 2013-05-22 12:59 ` rguenth at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-05-22 12:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57367
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Paolo Carlini from comment #6)
> Disappointing, Richard, that in 4.8/4.9 (vs 4.7) we don't seem to warn at
> all for the testcase in Comment#4 too. I'm wondering if the tree-vrp.c check
> couldn't be done a bit earlier, I don't know.
In 4.8/4.9 we optimize away the code and constant-propagate to the
printf (warning is inlined) before VRP. -O2 -fno-inline warns.
I've repeatedly said that the proper place for static analysis is IPA
time before early optimizers are running. You can trivially setup
constant/copy propagation without doing the actual transform there.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-05-22 12:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-22 10:51 [Bug c++/57367] New: Missing warning: array subscript is above array bounds Gildos at gmail dot com
2013-05-22 11:09 ` [Bug c++/57367] " glisse at gcc dot gnu.org
2013-05-22 11:38 ` rguenth at gcc dot gnu.org
2013-05-22 11:54 ` paolo.carlini at oracle dot com
2013-05-22 12:24 ` Gildos at gmail dot com
2013-05-22 12:33 ` paolo.carlini at oracle dot com
2013-05-22 12:50 ` paolo.carlini at oracle dot com
2013-05-22 12:59 ` rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).