Here is an example of a switch
statement, directly copied from this answer.
#include <stdio.h>
int main(){
int expr = 1;
switch (expr)
{
int i = 4;
f(i);
case 0:
i = 17;
/* falls through into default code */
default:
printf("%d\n", i);
}
}
Here is an equivalent code sample, written with goto
.
#include <stdio.h>
int main(){
int expr = 1;
if (expr == 0) goto label0;
else goto label1;
int i = 4;
f(i);
label0:
i = 17;
label1:
printf("%d\n", i);
}
Observe that, in both cases, when expr
is initialized to 1
, the initialization statement int i = 4
is not executed, so i
is not initialized. However, i
is defined, just as the quote in the question mentions.