This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: Why do call-clobbered local variables make the function not suitable for tail call optimization?


On Tue, Jul 20, 2004 at 04:34:57PM +0800, Jie Zhang wrote:
> Can somebody give me a hint why call-clobbered local 
> variables prevent the function from being tail call optimized?

int *global;

void f1(int *x)
{
  global = x;
  *x = 123;
}

int f2(void)
{
  clobber_the_stack();
  return *global;
}

int foo()
{
  int x;
  f1(&x);
  return f2();
}

int main()
{
  if (foo() != 123)
    abort ();
  return;
}


r~


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