https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49974
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=90905 --- Comment #15 from Martin Sebor <msebor at gcc dot gnu.org> --- GCC 10 issues two warnings for the first test case in comment #0: pr49974.C: In function ‘const X& g()’: pr49974.C:8:15: warning: function returns address of local variable [-Wreturn-local-addr] 8 | return f(x); // !!! | ^ pr49974.C:7:7: note: declared here 7 | X x; | ^ In function ‘const X& h()’: cc1plus: warning: function returns address of local variable [-Wreturn-local-addr] pr49974.C:7:7: note: declared here The second test case is not diagnosed (due to a similar problem as pr90905). The test cases in comment #8 are also not diagnosed.