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

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).