Xref: utzoo comp.lang.c:22307 comp.unix.wizards:18362
Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!uunet!mcsun!ukc!axion!fulcrum!masalla!igb
From: igb@fulcrum.bt.co.uk (Ian G Batten)
Newsgroups: comp.lang.c,comp.unix.wizards
Subject: ``Constants'' in case
Message-ID: <62@masalla.fulcrum.bt.co.uk>
Date: 27 Sep 89 14:24:44 GMT
Reply-To: igb@fulcrum.bt.co.uk (Ian G Batten)
Organization: BT Fulcrum, Birmingham, England
Lines: 19

Should this code fragment compile under (1) pcc (2) an ANSI compiler?

int x;

switch (x)
{
  case (int) 1:
   printf ("1\n");
   break;
  case (int) 2:
   printf ("2\n");
   break;
}

At least one compiler here rejects this, saying the case does not reduce
to a constant expression.  In fact, I suspect the general problem is
``is (int) constant a constant?''

ian