This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why do call-clobbered local variables make the function not suitablefor tail call optimization?
Hi Richard,
Richard Henderson wrote:
On Wed, Jul 21, 2004 at 01:56:26PM +0800, Jie Zhang wrote:
Thanks. Then how about tail recursion optimization? Why is it also
prevented by call-clobbered local variables?
A similar argument.
I finally got one, which is similar to your example.
int *global;
int foo()
{
int x;
if (global != 0)
{
x = 321;
return *global;
}
else
{
x = 123;
global = &x;
return foo ();
}
}
int main()
{
if (foo() != 123)
abort ();
return;
}
Thanks for your replies. Now I can understand tree-tailcall.c better. :-)
Regards
--
Jie