Recursive Functions (58)

34 Name: #!/usr/bin/anonymous : 2008-09-23 03:00 ID:cDy9us1s

>>33

Most C/C++ compilers that implement some kind of tail-call optimization (TCO) will refuse to do it for a large number of cases, including some of these:

  • Taking the address-of a stack allocated variable (using &)
  • If you use alloca() (or a C99-variable-sized array)
  • If you use setjmp() or exceptions
  • If you're using Visual C/C++ version 8.1 or earlier
  • If your tail call crosses a module boundary
  • If the number of arguments changes (sometimes!)
  • If it's an indirect function call
  • If any of the types change the ABI needed (int->float, etc)

It's funny: The same people who worry about stack smashing are the same people who try and recover when malloc() returns NULL.

This thread has been closed. You cannot post in this thread any longer.