Variable declaration after goto Label

The syntax simply doesn’t allow it. ยง6.8.1 Labeled Statements:

labeled-statement:
    identifier : statement
    case constant-expression : statement
    default : statement

Note that there is no clause that allows for a “labeled declaration”. It’s just not part of the language.

You can trivially work around this, of course, with an empty statement.

JUMP:;
int a = 0;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)