public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/95044] New: -Wreturn-local-addr false alarm in GCC 10.1.0 (regression)
@ 2020-05-10 23:56 eggert at cs dot ucla.edu
2020-05-11 7:30 ` [Bug c/95044] [10/11 Regression] -Wreturn-local-addr false alarm since r10-1741-gaac9480da1ffd037 marxin at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: eggert at cs dot ucla.edu @ 2020-05-10 23:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95044
Bug ID: 95044
Summary: -Wreturn-local-addr false alarm in GCC 10.1.0
(regression)
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: eggert at cs dot ucla.edu
Target Milestone: ---
Created attachment 48501
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48501&action=edit
Illustrate the -Wreturn-local-addr bug.
I ran into this problem when compiling GNU Emacs master with GCC 10.1.0 x86-64,
which I built from source on RHEL 7.7.
Compile the attached program u.c with:
gcc -S -Wreturn-local-addr -O2 u.c
The output is:
u.c: In function 'careadlinkat':
cc1: warning: function may return address of local variable
[-Wreturn-local-add\
r]
u.c:7:8: note: declared here
7 | char stack_buf[1024];
| ^~~~~~~~~
It's obviously impossible for the function to return that address. This false
alarm is not generated by GCC 9.3.0, so this is a regression.
There are really two bugs here:
1. GCC is ignoring the '#pragma GCC diagnostic ignored "-Wreturn-local-addr"'
and is outputting the diagnostic anyway.
2. GCC should not issue a diagnostic even if the pragma is absent, as it's
obviously impossible for the function to return the address of stack_buf.
Both bugs are new to GCC 10.1.0; they do not occur with GCC 9.3.0.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/95044] [10/11 Regression] -Wreturn-local-addr false alarm since r10-1741-gaac9480da1ffd037
2020-05-10 23:56 [Bug c/95044] New: -Wreturn-local-addr false alarm in GCC 10.1.0 (regression) eggert at cs dot ucla.edu
@ 2020-05-11 7:30 ` marxin at gcc dot gnu.org
2020-05-11 10:05 ` glisse at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-05-11 7:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95044
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org,
| |msebor at gcc dot gnu.org
Summary|-Wreturn-local-addr false |[10/11 Regression]
|alarm in GCC 10.1.0 |-Wreturn-local-addr false
|(regression) |alarm since
| |r10-1741-gaac9480da1ffd037
Last reconfirmed| |2020-05-11
Known to work| |9.3.0
Ever confirmed|0 |1
Known to fail| |10.1.0, 11.0
Status|UNCONFIRMED |NEW
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/95044] [10/11 Regression] -Wreturn-local-addr false alarm since r10-1741-gaac9480da1ffd037
2020-05-10 23:56 [Bug c/95044] New: -Wreturn-local-addr false alarm in GCC 10.1.0 (regression) eggert at cs dot ucla.edu
2020-05-11 7:30 ` [Bug c/95044] [10/11 Regression] -Wreturn-local-addr false alarm since r10-1741-gaac9480da1ffd037 marxin at gcc dot gnu.org
@ 2020-05-11 10:05 ` glisse at gcc dot gnu.org
2020-05-11 10:15 ` pinskia at gcc dot gnu.org
2020-05-11 14:28 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: glisse at gcc dot gnu.org @ 2020-05-11 10:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95044
--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
I think there is another very similar bug report.
# buf_1 = PHI <&stack_buf(2), buf_15(6)>
[...]
if (&stack_buf != buf_1)
in each branch, we thus know what buf_1 is, so we could replace it with buf_15
in
# _3 = PHI <_17(5), buf_1(4)>
return _3;
(or is that bad for register pressure?)
Or use it as a hint to thread that path, or add some logic to
Wreturn_local_addr, but that's getting more complicated.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/95044] [10/11 Regression] -Wreturn-local-addr false alarm since r10-1741-gaac9480da1ffd037
2020-05-10 23:56 [Bug c/95044] New: -Wreturn-local-addr false alarm in GCC 10.1.0 (regression) eggert at cs dot ucla.edu
2020-05-11 7:30 ` [Bug c/95044] [10/11 Regression] -Wreturn-local-addr false alarm since r10-1741-gaac9480da1ffd037 marxin at gcc dot gnu.org
2020-05-11 10:05 ` glisse at gcc dot gnu.org
@ 2020-05-11 10:15 ` pinskia at gcc dot gnu.org
2020-05-11 14:28 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-05-11 10:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95044
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Peeling off the first iteration might be the answer. Thread jumping could do
that but normally is not used for that, especially through other condtionals.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/95044] [10/11 Regression] -Wreturn-local-addr false alarm since r10-1741-gaac9480da1ffd037
2020-05-10 23:56 [Bug c/95044] New: -Wreturn-local-addr false alarm in GCC 10.1.0 (regression) eggert at cs dot ucla.edu
` (2 preceding siblings ...)
2020-05-11 10:15 ` pinskia at gcc dot gnu.org
@ 2020-05-11 14:28 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-05-11 14:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95044
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|NEW |RESOLVED
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
This looks like a duplicate of pr93644, including the test case involving the
careadlinkat function.
*** This bug has been marked as a duplicate of bug 93644 ***
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-05-11 14:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-10 23:56 [Bug c/95044] New: -Wreturn-local-addr false alarm in GCC 10.1.0 (regression) eggert at cs dot ucla.edu
2020-05-11 7:30 ` [Bug c/95044] [10/11 Regression] -Wreturn-local-addr false alarm since r10-1741-gaac9480da1ffd037 marxin at gcc dot gnu.org
2020-05-11 10:05 ` glisse at gcc dot gnu.org
2020-05-11 10:15 ` pinskia at gcc dot gnu.org
2020-05-11 14:28 ` 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).