This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: switch statement question
- To: Greg Hosler <hosler at lugs dot org dot sg>
- Subject: Re: switch statement question
- From: Dale Johannesen <dalej at apple dot com>
- Date: Wed, 13 Jun 2001 18:02:16 -0700
- Cc: gcc at gcc dot gnu dot org (gcc list)
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.)