This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/19972] New: Return Local function pointer
- From: "ppelissi at caramail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Feb 2005 08:37:42 -0000
- Subject: [Bug c/19972] New: Return Local function pointer
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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