I have a code using switch function and it gives the following error
supersonic_ob.cc:177: error:
jump to case label
supersonic_ob.cc:158: error: crosses initialization of ‘LaGenMatDouble delta_QQ’
What does it mean?
Printable View
I have a code using switch function and it gives the following error
supersonic_ob.cc:177: error:
jump to case label
supersonic_ob.cc:158: error: crosses initialization of ‘LaGenMatDouble delta_QQ’
What does it mean?
It means that the initializasion of LaGenMatDouble delta_QQ is done in one case and probably used in other...
You should place braces around case where the declaraton of the LaGenMatDouble delta_QQ is done
It's complaining because you might have writen code that looks like this, which wont print 42 when foo is 2 because it skipped over the line where foobar gets its value.
I thought that this usually only gave a warning though.By putting braces around the code in case 1, foobar is no longer in scope in case 2 and the problem becomes obvious, and you definitely get an error.Code:switch (foo) {
case 1:
int foobar = 21;
cout << foobar;
case 2:
cout << foobar*2;
break;
}