Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: net.lang.c Subject: Re: Problems with typechecking enumerated types Message-ID: <4072@utzoo.UUCP> Date: Fri, 13-Jul-84 13:22:38 EDT Article-I.D.: utzoo.4072 Posted: Fri Jul 13 13:22:38 1984 Date-Received: Fri, 13-Jul-84 13:22:38 EDT References: <109@dspo.UUCP> Organization: U of Toronto Zoology Lines: 22 > These results show the inconsistency in type checking enums - some > bizzare operations are allowed without any warning (like enum * enum) > and some reasonable operations are not allowed (like array indexing). > > Has a standard been developed for what operations should and should not > be allowed on enums? The addendum page in the V7 C Reference Manual says, in part: Objects of a given enumeration type are regarded as having a type distinct from objects of all other types... In other words, proper type-checking should probably bounce *all* your examples. If enums are distinct from all the integer types, for example, then none of the arithmetic operations apply to them. The problem is that enums were sort of patched into some of the existing compilers, and for that matter some of the existing compilers aren't too fussy about type checking to begin with. Don't confuse the eccentricities of the existing compilers with the definition of the language. -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,linus,decvax}!utzoo!henry