How come ANSI C allows extraneous code before any case labels within a switch statement?
#include <stdio.h>
int main(void) {
const int foo = 1;
switch (foo) {
printf("wut\n"); /* no label, doesn't output */
case 1:
printf("1\n");
break;
default:
printf("other\n");
break;
}
return 0;
}
compiled with
$ gcc -pedantic -Wall -Werror -Wextra -ansi test.c
It compiles without warnings and executes fine - sans "wut".