In the following C code, f calls g, and g calls h. Notice the goto in h, however: it will jump back to f if a satisfies a certain condition.
void h(int a)
{
if (a > 10)
goto out;
}
void g(int a, int b)
{
h(a);
}
void f(int a, int b)
{
g(a, b);
return;
out:
printf("b: %d\n", b);
}
My question is: how will the stack be if the goto is triggered? Will g and h be unstacked? And will f still print the right value of b? (or will it print it right only in some cases when I am lucky?)
(Please, I don't want to discuss if this is a good practice, or if this should be used at all. Also, consider that the actual code is complicated enough so that the compiler won't be smart enough to, e.g., optimize g out)
[I can give details on why I am doing this, if it matters -- I don't think it does]