Xref: utzoo comp.lang.c:22362 comp.unix.wizards:18385
Newsgroups: comp.lang.c,comp.unix.wizards
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: ``Constants'' in case
Message-ID: <1989Sep29.171831.29754@utzoo.uucp>
Organization: U of Toronto Zoology
References: <62@masalla.fulcrum.bt.co.uk>
Date: Fri, 29 Sep 89 17:18:31 GMT

In article <62@masalla.fulcrum.bt.co.uk> igb@fulcrum.bt.co.uk (Ian G Batten) writes:
>Should this code fragment compile under (1) pcc (2) an ANSI compiler? ...
>  case (int) 1:		...
>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?''

In K&R1, the list of operators allowed in constant expressions did not
include casts.  This was probably an oversight (casts were a recent addition
to the language at the time).  Casts are legal there in ANSI C.
-- 
"Where is D.D. Harriman now,   |     Henry Spencer at U of Toronto Zoology
when we really *need* him?"    | uunet!attcan!utzoo!henry henry@zoo.toronto.edu