This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Spurious warning
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Spurious warning
- From: "John H. Spicer" <jhs at edg dot com>
- Date: Mon, 31 Jan 2000 21:12:51 -0500 (EST)
This code results in the warning shown below that the function is returning
the address of a local variable. This warning is incorrect -- it computes
a size based on two local pointers, but the thing returned is most
certainly not a pointer.
struct A { int i; int j; };
int f(void)
{
struct A t[2];
return ((char*)(t+1)) - ((char *)(t));
}
t2.c: In function `f':
t2.c:5: warning: function returns address of local variable
John Spicer
jhs@edg.com