I think that this quote from the C Standard relative to the goto
statement will help to understand the quote relative to the switch statement.
6.8.6.1 The goto statement
1 The identifier in a goto statement shall name a label located
somewhere in the enclosing function. A goto statement shall not jump
from outside the scope of an identifier having a variably modified
type to inside the scope of that identifier.
In fact the swutch statement uses goto statements to pass the control to the selected label. So any such passing the control to a case label shall not skip a declaration of an object of a variable modified type. That is such a declaration either should be placed before a swict statement or inside the switch statement after all its labels.
And there is an example
goto lab3; // invalid: going INTO scope of VLA.
{
double a[n];
a[j] = 4.4;
lab3:
a[j] = 3.3;
goto lab4; // valid: going WITHIN scope of VLA.
a[j] = 5.5;
lab4:
a[j] = 6.6;
}
goto lab4; // invalid: going INTO scope of VLA.
that is the statements goto lab3;
and goto lab4;
are bypassing the declaraion double a[n];
.
Here is an example of a valid switch statement according to the footnote.
#include <stdio.h>
int main(void)
{
int n = 2;
switch ( n )
{
case 0:
break;
case 1:
break;
default: ;
int a[n];
for ( int i = 0; i < n; i++ ) a[i] = i;
int sum = 0;
for ( int i = 0; i < n; i++ ) sum += a[i];
printf( "sum = %d\n", sum );
}
return 0;
}
The program output is
sum = 1