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.