c++ - Why is jumping across variable definitions (with goto) allowed? -
c++ - Why is jumping across variable definitions (with goto) allowed? -
this question has reply here:
why ok jump scope of object of scalar type w/o initializer? 2 answersi confused variable definition, when playing goto
, switch
statements. below code accepted compiler:
goto label0; int j; // skipped "goto" label0: j = 3;
my questions are:
since definition ofint j;
skipped, how programme create object j
, later assign value in j = 3
? is code between goto
, label
compiled? is code between goto
, label
executed? (at run-time) does variable definition happen @ compile-time(or more proper term) or run-time? (i inquire new question focusing more on relative order of variable definition , compilation , execution. )
just found question close answer:
why ok jump scope of object of scalar type w/o initializer?
to summarize , reply questions:
thegoto
run-time thing. definition still happens; yes compiled. no not executed. definition happens despite part skipped goto
. c++ variables
Comments
Post a Comment