[Bug c/37231] GCC does not compile code with label statements that are followed by a declaration

2010-05-09 Thread alex dot pyattaev at gmail dot com


--- Comment #7 from alex dot pyattaev at gmail dot com  2010-05-09 10:29 
---
I have encountered the bug with switch construct. And the problem is not the
error message, but the fact that it is still compiling just fine this code:
switch (chan_prop.model_type)
{
case CM_STATIC:
return static_channel_model(src, ntransmitters, dst,
&chan_prop);
case CM_FRISS:
return friss_channel_model(src, ntransmitters, dst,
   &chan_prop);
default:
return -1;
}
There should be some consistency at least! I'd like to see this fixed properly.
The compiler should be perfectly predictable, and not like "Sorry, i don't like
this construct here... put a semicolon please".

I'd like this bug to be reopened and FIXED PROPERLY

gcc --version =  (Gentoo 4.4.3-r2 p1.2) 4.4.3


-- 

alex dot pyattaev at gmail dot com changed:

   What|Removed |Added

 CC|            |alex dot pyattaev at gmail
   |    |dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37231



[Bug c/37231] GCC does not compile code with label statements that are followed by a declaration

2010-05-09 Thread alex dot pyattaev at gmail dot com


--- Comment #9 from alex dot pyattaev at gmail dot com  2010-05-09 19:07 
---
(In reply to comment #7)
> I have encountered the bug with switch construct. And the problem is not the
> error message, but the fact that it is still compiling just fine this code:
> switch (chan_prop.model_type)
> {
> case CM_STATIC:
> return static_channel_model(src, ntransmitters, dst,
> &chan_prop);
> case CM_FRISS:
> return friss_channel_model(src, ntransmitters, dst,
>&chan_prop);
> default:
> return -1;
> }
> There should be some consistency at least! I'd like to see this fixed 
> properly.
> The compiler should be perfectly predictable, and not like "Sorry, i don't 
> like
> this construct here... put a semicolon please".
> 
> I'd like this bug to be reopened and FIXED PROPERLY
> 
> gcc --version =  (Gentoo 4.4.3-r2 p1.2) 4.4.3
> 

A good example of seemingly normal code is following:
 switch (whatever)
{
case 1:
int i=0;
i++;
printf("%d",i);   
break;
}
It is technically perfectly legal to declare i as a local variable. However,
the compiler issues an error. And it is absolutely not clear why "int i=0;" is
not a statement. That is probably the only really annoying case. Moving
declaration of i into a code block solves the issue. I spent like 10 minutes
trying to find out why perfectly legal code would not compile.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37231



[Bug c/37231] GCC does not compile code with label statements that are followed by a declaration

2010-05-09 Thread alex dot pyattaev at gmail dot com


--- Comment #11 from alex dot pyattaev at gmail dot com  2010-05-09 23:29 
---
(In reply to comment #10)
> (In reply to comment #9)
> > 
> > A good example of seemingly normal code is following:
> >  switch (whatever)
> > {
> > case 1:
> > int i=0;
> > i++;
> > printf("%d",i);   
> > break;
> > }
> > It is technically perfectly legal to declare i as a local variable. However,
> > the compiler issues an error. And it is absolutely not clear why "int i=0;" 
> > is
> > not a statement. That is probably the only really annoying case. Moving
> > declaration of i into a code block solves the issue. I spent like 10 minutes
> > trying to find out why perfectly legal code would not compile.
> > 
> 
> Not to beat a dead horse here but...
> 
> Because that is *not* perfectly legal C code, and will not be valid C++ code 
> if
> you add another case label after it (jump over initialization)?  A declaration
> ("int i") is not a statement.
> 
> That fails on both MSVC and gcc.  In fact, MSVC will still barf even after
> adding a semicolon after the label to make it a statement. (MSVC error is
> "error 2143: missing ';' before type")
> 
Ok, lets have pity for dead horse. Let it be as it is=)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37231