vs2010 c++ tail call optimization
问题 Consider the following code: int fac_aux( int x, int res ) { if( x == 1 ) return res; else return fac_aux( x - 1, res * x ); } int fac( int x ) { return fac_aux( x, 1 ); } int main() { int x = fac( 50 ); std::cout << x; return 0; } According to generated asm file everything is ok, tail call is optimized. Try to replace int x = fac( 50 ); with int x = fac_aux( 50, 1 ); Strange enough, but tail call optimization is disappeared. As far as I remember there was no such a strange compiler behaviour