At what moment is memory typically allocated for local variables in C++?
问题 I'm debugging a rather weird stack overflow supposedly caused by allocating too large variables on stack and I'd like to clarify the following. Suppose I have the following function: void function() { char buffer[1 * 1024]; if( condition ) { char buffer[1 * 1024]; doSomething( buffer, sizeof( buffer ) ); } else { char buffer[512 * 1024]; doSomething( buffer, sizeof( buffer ) ); } } I understand, that it's compiler-dependent and also depends on what optimizer decides, but what is the typical