public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/101679] New: duplicate warning offset outside bounds of constant string
@ 2021-07-29 17:49 msebor at gcc dot gnu.org
2021-07-29 21:22 ` [Bug middle-end/101679] triplicate " msebor at gcc dot gnu.org
2021-07-29 21:30 ` msebor at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-29 17:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101679
Bug ID: 101679
Summary: duplicate warning offset outside bounds of constant
string
Product: gcc
Version: 12.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: ---
Only one instance of -Warray-bounds should be reported the access below but GCC
issues two. The warning is issued from c_strlen() with the first instance
during lowering and the second during (or just before) expansion. The first
instance calls suppress_warning(arg, OPT_Warray_bounds) which is checked again
before issuing the second instance by calling warning_suppressed_p (arg,
OPT_Warray_bounds). The problem is that the first time arg is an ADDR_EXPR but
VAR_DECL the second. Stripping the ADDR_EXPR and disabling the warning for its
operand is not a solution because it would disable warnings for invalid uses of
the same operand in other statements, both in the same function or (for global
variables) in others.
$ cat a.c && gcc -S -Wall a.c
const char s0[0] = { };
char* f (char *d)
{
return __builtin_strcpy (d, s0);
}
a.c: In function ‘f’:
a.c:5:31: warning: offset ‘0’ outside bounds of constant string
[-Warray-bounds]
5 | return __builtin_strcpy (d, s0);
| ^~
a.c:1:12: note: ‘s0’ declared here
1 | const char s0[0] = { };
| ^~
a.c:5:10: warning: offset ‘0’ outside bounds of constant string
[-Warray-bounds]
5 | return __builtin_strcpy (d, s0);
| ^~~~~~~~~~~~~~~~~~~~~~~~
a.c:1:12: note: ‘s0’ declared here
1 | const char s0[0] = { };
| ^~
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-29 21:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29 17:49 [Bug middle-end/101679] New: duplicate warning offset outside bounds of constant string msebor at gcc dot gnu.org
2021-07-29 21:22 ` [Bug middle-end/101679] triplicate " msebor at gcc dot gnu.org
2021-07-29 21:30 ` 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).