Tail recursion in gcc/g++
With -O2 enabled, gcc will perform tail call optimization, if possible. Now, the question is: When is it possible? It is possible to eliminate a single recursive call whenever the recursive call happens either immediately before or inside the (single) return statement, so there are no observable side effects afterwards other than possibly returning a … Read more