This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: switch statement question



On Wednesday, June 13, 2001, at 06:13  PM, Greg Hosler wrote:

> I have a switch / case statement that is breaking under recent versions 
> of
> gcc, that used to be ok. I am guessing that the the language 
> specification
> has been tightened up (or the implementation). In my code, the case 
> values are
> longs (as opposed to int's) - I get compiler warnings, and it appears 
> that
> either the case code is not generated, or the switch is not handling 
> the long's
> in the fashion that it used to.
>
> what is the definition of what is allowed for the "case values" of
> switch statements ?

They must be "integral constant expressions", which includes long's.  
However, they will be converted to the type of the expression in the 
switch() statement before comparison, so that should be long also 
(unlike most other cases of long/int mismatch, where the int would be 
lengthened).  (What the standard says.)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]