Package: gcc-3.3 [This is also present in gcc-3.2, and probably all 3.x versions; it is inapplicable for 2.95, which didn't support dynamic arrays]
int main(void) { int foo = 0; int bar; int len = 5; switch(foo) { case 0: bar = 1; char buf[len]; } } [EMAIL PROTECTED]:~$ gcc-3.2 -g -o foo foo.c foo.c: In function `main': foo.c:6: warning: unreachable code at beginning of switch statement Note that this only occurs at -g2 or higher; I'm not sure why offhand. The line number is at best misleading; the complaint is about the scope of the dynamic array buf. I haven't investigated it, because I'm mildly familiar with the code in gcc that's responsible (most of gcc/stmt.c), and it's utterly disgusting. However, I recognise the symptoms; it is likely that the code to set up the dynamic array has been inserted at the top of the binding contour - between the { and the case - which is invalid, as that space is always jumped over. This is supported by observing that if you manually insert a new contour, the warning disappears: int main(void) { int foo = 0; int bar; int len = 5; switch(foo) { case 0: { bar = 1; char buf[len]; } } } I'm not sure whether the original code is supposed to compile or not; I suspect that it currently miscompiles. What the heck is the scope of a variable declared in this position? -- .''`. ** Debian GNU/Linux ** | Andrew Suffield : :' : http://www.debian.org/ | `. `' | `- -><- |
signature.asc
Description: Digital signature