Export (0) Print
Expand All

Compiler Error C2362

initialization of 'identifier' is skipped by 'goto label'

When compiling with /Za, jumping to the label prevents the identifier from being initialized.

You cannot jump past a declaration with an initializer unless the declaration is enclosed in a block that is not entered, or the variable has already been initialized.

The following sample generates C2326:

// C2362.cpp
// compile with: /Za
int main() {
   goto label1;
   int i = 1;      // C2362, initialization skipped
label1:;
}

Possible resolution:

// C2362b.cpp
// compile with: /Za
int main() {
   goto label1;
   {
      int j = 1;   // OK, this block is never entered
   }
label1:;
}
Show:
© 2015 Microsoft