Q:

tail recursion optimization happens in visual studio 10 x64 debug but not in release?

originally I got a stackoverflow exception in x86 mode. As I noticed that x64 would optimize tail recursion so i switched to compile in x64. And it worked out gracefully in debug mode.. However when I tried to run the release code.. it throwed stackoverflow again.. any possible reason?

A:

The rules for when tail recursion optimizations are applied are complicated and ever-changing.
I would strongly recommend that you don't rely on tail recursion from a correctness point of view.

