This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Spurious warning


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]