Re:How recursion got into programming: a comedy of errors
by supergauntlet on Wednesday July 23, 2014 @07:32AM
(#8073759)
C++ optimizes only with -O2 or /O2 passed to the compiler (for GCC and MSVC++, not sure about Clang).
[ Parent
| on HN ]
Re:How recursion got into programming: a comedy of errors
by pflanze on Wednesday July 23, 2014 @08:59AM
(#8074083)
You can't count on it in the general case even with gcc (even when taking care to heed the restrictions like not passing pointers to data on the stack, and putting all functions into the same compilation unit). I did tests a couple years ago where it would compile up to about a handful of mutually recursive functions with TCO, then when you added one more, it would disable TCO. I guess because some algorithm will stop analyzing the call graph past a certain mark and then disallow TCO from being applied.