https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63446
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2014-10-03 00:00:00 |2021-4-16 Known to fail| |10.2.0, 11.0, 4.6.4, 4.9.4, | |5.5.0, 6.4.0, 7.2.0, 8.3.0, | |9.1.0 CC| |msebor at gcc dot gnu.org Severity|normal |enhancement Blocks| |49974 --- Comment #9 from Martin Sebor <msebor at gcc dot gnu.org> --- GCC 11 improves the message by including a note that mentions the uninitialized variable. In this case it doesn't completely solve the problem because the variable it points to is initialized but it should help. pr63446.C: In function ‘int func()’: pr63446.C:15:14: warning: ‘x’ is used uninitialized [-Wuninitialized] 15 | return f.ref; | ^~~ pr63446.C:8:9: note: ‘x’ was declared here 8 | int x = 42; | ^ But the underlying bug here is returning a reference to a local variable, so the warning to improve is -Wreturn-local-addr. That will diagnose the return statement in make_foo(). Bug 49974 tracks that enhancement. With that, the additional -Wuninitialized issued in func() would just help clarify the consequences of the bug but not otherwise be essential. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49974 [Bug 49974] missing -Wreturn-local-addr for indirectly returning reference to local/temporary