Problems with typechecking enumerated types

Henry Spencer henry at utzoo.UUCP
Sat Jul 14 03:22:38 AEST 1984


> 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



More information about the Comp.lang.c mailing list