Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is jumping to the beginning of the block equivalent to "entering the block"?

Consider the below example code:

int jump_count = 0;

int main()
{
entry:
    int obj = jump_count;
    printf("%d\n", obj);
    jump_count++;

    if(jump_count < 2) goto entry;

    return 0;
}

Is my jumping to the beginning of the block (as mentioned in the above code) equivalent to "entering the block"?

like image 533
Cinverse Avatar asked Oct 15 '25 16:10

Cinverse


1 Answers

You're not exiting the block when you do the jump, and the object's lifetime starts at the beginning of the block, so you're still working with the same object as when you first entered the block.

like image 79
dbush Avatar answered Oct 18 '25 11:10

dbush