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 But not for `apply' (and it produces invalid code, which is normal). GCC Version: Using built-in specs. Configured with: ../configure --prefix=/global/morpork/gcc-4.0-20050130 Thread model: posix gcc version 4.0.0 20050130 (experimental) -- Summary: Return Local function pointer Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ppelissi at caramail dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19972