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]

Re: proper tail recursion for gcc


> When foo_with_bar returns, it will return to foo's caller, which
> will pop off b and c.  a remains on the stack, but does no harm.
> When foo's caller returns, a will get popped, just as if a had
> been alocated with alloca.
> 
> This will fail if foo's caller is compiled to not use a frame pointer,
> since the stack pointer will not be where it expects it.

And even if it has been compiled with a frame pointer, there can
be a stack overflow if the call is done in a loop with many iterations.

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