https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45821
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2015-09-18 CC| |manu at gcc dot gnu.org Depends on| |60517 Ever confirmed|0 |1 --- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Andrew Gaul from comment #3) > int *function_return_local(void) > { > int x = 0; > return &x; > } > > int *statement_expression_return_local(void) > { > int *y = ({ > int x = 0; > &x; > }); > return y; > } We now warn at -O2: test.c:14:10: warning: function returns address of local variable [-Wreturn-local-addr] return y; ^ test.c:11:11: note: declared here int x = 0; ^ but only because we return y. For this testcase, int statement_expression_return_local(void) { int *y = ({ int x = 0; &x; }); return *y; } we get: test.c:14:10: warning: ‘x’ is used uninitialized in this function [-Wuninitialized] return *y; ^ which is a bit confusing (and not the same warning). Possibly related to 60517. it would be good to add the testcase Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60517 [Bug 60517] warning/error for taking address of member of a temporary object