public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/99676] New: missing detail in warning for passing smaller array to bigger argument
@ 2021-03-19 22:22 msebor at gcc dot gnu.org
2021-03-19 22:23 ` [Bug middle-end/99676] " msebor at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-19 22:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99676
Bug ID: 99676
Summary: missing detail in warning for passing smaller array to
bigger argument
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
The warning(s) below are confusing:
1) each mentions the argument type is 'int *' when it actually uses 'int[4]' to
trigger, and
2) it doesn't point to the declaration of the object or subobject whose size it
uses.
In cases like pr99673 the missing details make the warning harder than
necessary to understand and decide if it's a false positive.
$ cat x.c && gcc -O -S -Wall x.c
struct A { int a[2], b[2]; };
void f (int[4], int[4]);
void g (int *p, int *q)
{
f (p, q);
}
void h (struct A *p)
{
g (p->a, p->b);
}
In function ‘g’,
inlined from ‘h’ at x.c:12:3:
x.c:7:3: warning: ‘f’ accessing 16 bytes in a region of size 8
[-Wstringop-overflow=]
7 | f (p, q);
| ^~~~~~~~
x.c: In function ‘h’:
x.c:7:3: note: referencing argument 1 of type ‘int *’
In function ‘g’,
inlined from ‘h’ at x.c:12:3:
x.c:7:3: warning: ‘f’ accessing 16 bytes in a region of size 8
[-Wstringop-overflow=]
x.c: In function ‘h’:
x.c:7:3: note: referencing argument 2 of type ‘int *’
x.c:3:6: note: in a call to function ‘f’
3 | void f (int[4], int[4]);
| ^
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug middle-end/99676] missing detail in warning for passing smaller array to bigger argument
2021-03-19 22:22 [Bug middle-end/99676] New: missing detail in warning for passing smaller array to bigger argument msebor at gcc dot gnu.org
@ 2021-03-19 22:23 ` msebor at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-03-19 22:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99676
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Blocks| |88443
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The warning should also not be -Wstringop-overflow or -Wstringop-overread
(which are meant to be about accesses by functions declared in <string.h> and
maybe also direct string accesses by pointers) but probably -Warray-bounds.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
[Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-19 22:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 22:22 [Bug middle-end/99676] New: missing detail in warning for passing smaller array to bigger argument msebor at gcc dot gnu.org
2021-03-19 22:23 ` [Bug middle-end/99676] " msebor 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).