I am confused with variable definition, when playing with goto
and switch
statements.
The below code were accepted by compiler:
goto label0;
int j; // skipped by "goto"
label0:
j = 3;
My questions are:
- Since the definition of
int j;
is skipped, how will the program create objectj
and later assign value to it inj = 3
? - Is the code between
goto
andlabel
compiled? - Is the code between
goto
andlabel
executed? (at run-time) - Does variable definition happen at compile-time(or more proper term) or run-time?
(I ask this as a new question focusing more on the relative order of variable definition and compilation and execution. )