enricojoerns.de

My favourite bugs for C

21.04.2014

Declare variable inside switch

switch (2) {
int x = 10;
case 2: printf("Case 2: %d\n",x);
break;
}

is the same as

goto 2;
int x = 10;
2:
printf("Case 2: %d\n",x);

Which is the same as...

printf("Case 2: %d\n",x);