public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/95278] New: attribute nonstring effect on arguments in function declaration that's not a definition
@ 2020-05-22 19:40 msebor at gcc dot gnu.org
0 siblings, 0 replies; only message in thread
From: msebor at gcc dot gnu.org @ 2020-05-22 19:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95278
Bug ID: 95278
Summary: attribute nonstring effect on arguments in function
declaration that's not a definition
Product: gcc
Version: 10.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: ---
strlen calls in both functions below should be diagnosed because the
declaration with the attribute is likely to be in a header and thus come first,
and it's what determines what calls can be diagnosed. Unfortunately, the more
likely case is not diagnosed.
$ cat z.c && gcc -S -Wall -Wextra z.c
int f (const char *);
int f (const char __attribute__ ((nonstring)) *p)
{
return __builtin_strlen (p); // warning (good)
}
int g (const char __attribute__ ((nonstring))*);
int g (const char *p)
{
return __builtin_strlen (p); // missing warning
}
z.c: In function ‘f’:
z.c:5:10: warning: ‘__builtin_strlen’ argument 1 declared attribute ‘nonstring’
[-Wstringop-overflow=]
5 | return __builtin_strlen (p); // warning (good)
| ^~~~~~~~~~~~~~~~~~~~
z.c:3:48: note: argument ‘p’ declared here
3 | int f (const char __attribute__ ((nonstring)) *p)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-05-22 19:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22 19:40 [Bug middle-end/95278] New: attribute nonstring effect on arguments in function declaration that's not a definition 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).