In Visual Studio 2013, C++, unmanaged code, I have a function like
void SomeFunc()
{
if (…some condition…) {
int x;
// do some stuff with x
} else {
int y;
// do some stuff with y
}
} // end SomeFunc
Are x and y both allocated on the stack on every call, or is each variable allocated when and if its branch is taken? For integer variables this is not very important, but I want to understand the behavior in the general case, in which branches may have lots of stack data, including non-trivial objects. Thanks.