https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19972
Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2005-12-18 01:39:05 |2017-7-24 CC| |egallager at gcc dot gnu.org Summary|Return Local (nested) |-Wreturn-local-addr misses |function pointer |return of local (nested) | |function pointer --- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> --- (In reply to Patrick Pelissier from comment #0) > When returning local function pointer, it doesn't produce any warnings. > For example: > > int *h() { > int z; > return &z; > } > > int (*apply (int (*f) (const void *, const void *), void *a))(const void *) > { > int zozo(const void * b) { return f(a,b); }; > return &zozo; > } > > Compile with -O2 -Wall, it produces a warning for h: > > ttt.c: In function 'h': > ttt.c:17: warning: function returns address of local variable > With a newer gcc, this warning is now: $ /usr/local/bin/gcc -c -O2 -Wall 19972.c 19972.c: In function ‘h’: 19972.c:3:9: warning: function returns address of local variable [-Wreturn-local-addr] return &z; ^~ Retitling this bug to better describe situation.