public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/98548] New: missing warning on strcmp with a nonstring member
@ 2021-01-05 21:11 msebor at gcc dot gnu.org
2021-12-11 7:40 ` [Bug middle-end/98548] " pinskia at gcc dot gnu.org
2021-12-12 11:55 ` redi at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-01-05 21:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98548
Bug ID: 98548
Summary: missing warning on strcmp with a nonstring member
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
-Wstringop-overread detects the misuse of the nonstring array as a strcmp
argument in f() but not in g(). Both calls should trigger a warning.
$ cat b.c && gcc -O2 -S -Wall -Wextra b.c
struct A
{
char a[4] __attribute__ ((nonstring));
char b[8];
};
int f (void)
{
extern struct A a;
return 0 == __builtin_strcmp (a.a, a.b); // warning (good)
}
int g (struct A *p)
{
return 0 == __builtin_strcmp (p->a, p->b); // missing warning
}
b.c: In function ‘f’:
b.c:10:15: warning: ‘__builtin_strcmp’ argument 1 declared attribute
‘nonstring’ is smaller than the specified bound 8 [-Wstringop-overread]
10 | return 0 == __builtin_strcmp (a.a, a.b);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
b.c:3:8: note: argument ‘a’ declared here
3 | char a[4] __attribute__ ((nonstring));
| ^
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/98548] missing warning on strcmp with a nonstring member
2021-01-05 21:11 [Bug middle-end/98548] New: missing warning on strcmp with a nonstring member msebor at gcc dot gnu.org
@ 2021-12-11 7:40 ` pinskia at gcc dot gnu.org
2021-12-12 11:55 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-11 7:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98548
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |needs-bisection
Known to fail| |11.2.0
Known to work| |12.0
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks fixed on the trunk:
<source>: In function 'f':
<source>:11:15: warning: '__builtin_strcmp' argument 1 declared attribute
'nonstring' is smaller than the specified bound 8 [-Wstringop-overread]
11 | return 0 == __builtin_strcmp (a.a, a.b); // warning (good)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:4:8: note: argument 'a' declared here
4 | char a[4] __attribute__ ((nonstring));
| ^
<source>: In function 'g':
<source>:16:15: warning: '__builtin_strcmp' argument 1 declared attribute
'nonstring' is smaller than the specified bound 8 [-Wstringop-overread]
16 | return 0 == __builtin_strcmp (p->a, p->b); // missing warning
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:4:8: note: argument 'a' declared here
4 | char a[4] __attribute__ ((nonstring));
| ^
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/98548] missing warning on strcmp with a nonstring member
2021-01-05 21:11 [Bug middle-end/98548] New: missing warning on strcmp with a nonstring member msebor at gcc dot gnu.org
2021-12-11 7:40 ` [Bug middle-end/98548] " pinskia at gcc dot gnu.org
@ 2021-12-12 11:55 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-12 11:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98548
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
GCC started to warn for f() at r12-2793:
Move more code to new gimple-ssa-warn-access pass.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-12 11:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05 21:11 [Bug middle-end/98548] New: missing warning on strcmp with a nonstring member msebor at gcc dot gnu.org
2021-12-11 7:40 ` [Bug middle-end/98548] " pinskia at gcc dot gnu.org
2021-12-12 11:55 ` redi 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).