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?
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
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
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; }
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"