If I jump into a block like in this example, jumping "over" the declarations,
#include <stdio.h>
int main(int argc, char *argv[]){
int counter = 0;
goto jump;
{
static int st = -9;
int au = -9;
jump:
printf("st = %d\n", st);
printf("au = %d\n", au);
au++;
st++;
counter++;
}
if(counter < 10) goto jump;
return 0;
}
I can compile it with gcc --std=c89 -pedantic.
It seems that you can't really jump "over" declarations: the variables are still declared, even if the lines in which those declarations are made are never reached.
But somehow you can jump over definitions...
stas a static variable gets initialized with the value -9 and counts up to 0.augets initialized with the value 0 and counts up to 9.
Is 1. and/or 2. a behavior which is necessitated by the C standard?