Building firefox with gcc8 trunk i get this error: In file included from /root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/memory/build/Unified_cpp_memory_build0.cpp:2:0: /root/firefox-gcc-last/memory/build/mozjemalloc.cpp: In member function 'void** AddressRadixTree<Bits>::GetSlot(void*, bool)': /root/firefox-gcc-last/memory/build/mozjemalloc.cpp:1695:10: error: address of local variable 'node' returned [-Werror=return-local-addr] void** node; ^~~~ cc1plus: all warnings being treated as errors The entire context can be found here: [1] http://searchfox.org/mozilla-central/rev/a984558fa2bbde6492d3fb918496fc0b0835b2ce/memory/build/mozjemalloc.cpp#1721 [2] http://searchfox.org/mozilla-central/rev/a984558fa2bbde6492d3fb918496fc0b0835b2ce/memory/build/mozjemalloc.cpp#1698 It can easily be seen that by just analysing [2] 'node' only points somewhere in 'mRoot'.
Can you please attach preprocessed source + full g++ command line? Thanks.
the command line: /usr/bin/g++-8 -std=gnu++11 -o Unified_cpp_memory_build0.o -c -I/root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/dist/system_wrappers -include /root/firefox-gcc-last/config/gcc_hidden.h -DDEBUG=1 -DMOZ_MEMORY_IMPL -DMOZ_HAS_MOZGLUE -I/root/firefox-gcc-last/memory/build -I/root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/memory/build -I/root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/dist/include -I/root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/dist/include/nspr -I/root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/dist/include/nss -fPIC -DMOZILLA_CLIENT -include /root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/mozilla-config.h -MD -MP -MF .deps/Unified_cpp_memory_build0.o.pp -Wall -Wc++11-compat -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wwrite-strings -Wno-invalid-offsetof -Wc++14-compat -Wc++1z-compat -Wduplicated-cond -Wimplicit-fallthrough -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wformat -Wformat-overflow=2 -fno-exceptions -fno-strict-aliasing -fno-rtti -fno-exceptions -fno-math-errno -pthread -pipe -g -freorder-blocks -Os -fno-omit-frame-pointer -Werror -Wno-unused-function -Wno-error=uninitialized -fdiagnostics-color /root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/memory/build/Unified_cpp_memory_build0.cpp
Created attachment 42389 [details] preprocessed file
Seems to have started with r253599. Will try to reduce it now.
Reduced testcase: void *b[10]; template <int N> void ** foo (int x) { void **a = b; return &a[x]; } void ** bar (int x) { return foo <0> (x); }
Created attachment 42392 [details] gcc8-pr82600.patch Untested fix. The problem is that the -Wreturn-local-addr implementation requires full folding of the expressions such that it will actually not see an ARRAY_REF if the corresponding DECL isn't an array, but a pointer. Such folding isn't performed if processing_template_decl though (no folding is done, cp_fully_fold just returns the passed argument immediately).
(In reply to Andi from comment #0) > Building firefox with gcc8 trunk i get this error: This is a warning, not an error. If you use -Werror to cause compilation to fail that's your choice, but it's still just a warning as far as we're concerned. If you can't build because you choose to use -Werror then don't use -Werror.
(In reply to Jonathan Wakely from comment #7) > (In reply to Andi from comment #0) > > Building firefox with gcc8 trunk i get this error: > > This is a warning, not an error. > > If you use -Werror to cause compilation to fail that's your choice, but it's > still just a warning as far as we're concerned. > > If you can't build because you choose to use -Werror then don't use -Werror. Indeed the build was ran with -Werror since we wanted to see what are our blockers.
Author: jakub Date: Thu Oct 19 14:24:39 2017 New Revision: 253899 URL: https://gcc.gnu.org/viewcvs?rev=253899&root=gcc&view=rev Log: PR c++/82600 * typeck.c (check_return_expr): Don't call maybe_warn_about_returning_address_of_local in templates. * g++.dg/warn/Wreturn-local-addr-4.C: New test. Added: trunk/gcc/testsuite/g++.dg/warn/Wreturn-local-addr-4.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog
Fixed.