public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/81172] Expected new warning option -Warray-bounds-pointer-arithmetic
[not found] <bug-81172-4@http.gcc.gnu.org/bugzilla/>
@ 2020-04-13 20:27 ` msebor at gcc dot gnu.org
2020-04-14 5:58 ` egallager at gcc dot gnu.org
1 sibling, 0 replies; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-04-13 20:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81172
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |10.0
Resolution|--- |FIXED
Blocks| |56456
Status|NEW |RESOLVED
--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
For the slightly modified test case GCC 10 issues the expected warnings in the
expected cases (i.e., unless the code is removed as unused, etc.) So I think
this can be resolved as fixed. (There are plenty of other cases that still
aren't diagnosed; please open new bugs for those if they aren't already being
tracked under pr56456).
$ cat pr81172.c && gcc -O2 -S -Wall pr81172.c
int a[] = {1,2,3,4};
int* f (void)
{
int *p = a + 5;
return p;
}
const char s[] = "aaa", t[] = "bbbbb";
const char* g (void)
{
const char *p = s + __builtin_strlen (t);
return p;
}
const char* h (void)
{
return s + 'c';
}
pr81172.c: In function ‘f’:
pr81172.c:5:8: warning: array subscript 5 is outside array bounds of ‘int[4]’
[-Warray-bounds]
5 | int *p = a + 5;
| ^
pr81172.c:1:5: note: while referencing ‘a’
1 | int a[] = {1,2,3,4};
| ^
pr81172.c: In function ‘g’:
pr81172.c:13:15: warning: array subscript 5 is outside array bounds of ‘const
char[4]’ [-Warray-bounds]
13 | const char *p = s + __builtin_strlen (t);
| ^
pr81172.c:9:12: note: while referencing ‘s’
9 | const char s[] = "aaa", t[] = "bbbbb";
| ^
pr81172.c: In function ‘h’:
pr81172.c:19:12: warning: array subscript 99 is outside array bounds of ‘const
char[4]’ [-Warray-bounds]
19 | return s + 'c';
| ~~^~~~~
pr81172.c:9:12: note: while referencing ‘s’
9 | const char s[] = "aaa", t[] = "bbbbb";
| ^
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456
[Bug 56456] [meta-bug] bogus/missing -Warray-bounds
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug middle-end/81172] Expected new warning option -Warray-bounds-pointer-arithmetic
[not found] <bug-81172-4@http.gcc.gnu.org/bugzilla/>
2020-04-13 20:27 ` [Bug middle-end/81172] Expected new warning option -Warray-bounds-pointer-arithmetic msebor at gcc dot gnu.org
@ 2020-04-14 5:58 ` egallager at gcc dot gnu.org
1 sibling, 0 replies; 2+ messages in thread
From: egallager at gcc dot gnu.org @ 2020-04-14 5:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81172
Eric Gallager <egallager at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |egallager at gcc dot gnu.org
--- Comment #7 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #6)
> For the slightly modified test case GCC 10 issues the expected warnings in
> the expected cases (i.e., unless the code is removed as unused, etc.) So I
> think this can be resolved as fixed. (There are plenty of other cases that
> still aren't diagnosed; please open new bugs for those if they aren't
> already being tracked under pr56456).
>
> $ cat pr81172.c && gcc -O2 -S -Wall pr81172.c
>
> int a[] = {1,2,3,4};
>
> int* f (void)
> {
> int *p = a + 5;
> return p;
> }
>
> const char s[] = "aaa", t[] = "bbbbb";
>
> const char* g (void)
> {
> const char *p = s + __builtin_strlen (t);
> return p;
> }
>
> const char* h (void)
> {
> return s + 'c';
> }
> pr81172.c: In function ‘f’:
> pr81172.c:5:8: warning: array subscript 5 is outside array bounds of
> ‘int[4]’ [-Warray-bounds]
> 5 | int *p = a + 5;
> | ^
> pr81172.c:1:5: note: while referencing ‘a’
> 1 | int a[] = {1,2,3,4};
> | ^
> pr81172.c: In function ‘g’:
> pr81172.c:13:15: warning: array subscript 5 is outside array bounds of
> ‘const char[4]’ [-Warray-bounds]
> 13 | const char *p = s + __builtin_strlen (t);
> | ^
> pr81172.c:9:12: note: while referencing ‘s’
> 9 | const char s[] = "aaa", t[] = "bbbbb";
> | ^
> pr81172.c: In function ‘h’:
> pr81172.c:19:12: warning: array subscript 99 is outside array bounds of
> ‘const char[4]’ [-Warray-bounds]
> 19 | return s + 'c';
> | ~~^~~~~
> pr81172.c:9:12: note: while referencing ‘s’
> 9 | const char s[] = "aaa", t[] = "bbbbb";
> | ^
I'd think breaking this into a separate sub-option as previously suggested
would still be useful; I can see people wanting other -Warray-bounds warnings
but not these, and vice versa
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-14 5:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-81172-4@http.gcc.gnu.org/bugzilla/>
2020-04-13 20:27 ` [Bug middle-end/81172] Expected new warning option -Warray-bounds-pointer-arithmetic msebor at gcc dot gnu.org
2020-04-14 5:58 ` egallager 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).