Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uflorida!novavax!proxftl!twwells!bill From: bill@twwells.uucp (T. William Wells) Newsgroups: comp.std.c Subject: Re: are enums integers in ANSI? Message-ID: <219@twwells.uucp> Date: 27 Nov 88 11:02:03 GMT References: <8457@alice.UUCP> Reply-To: bill@twwells.UUCP (T. William Wells) Organization: None, Ft. Lauderdale Lines: 34 Summary: Expires: Sender: Followup-To: Distribution: Keywords: In article <8457@alice.UUCP> dmr@alice.UUCP writes: : Here is a more subtle example. : : int x; : enum e x; : : A compiler is permitted to accept this if, for example, it decides : that the integral type all enums are compatible with is int. That bothers me. I thought the purpose of the compatible/composite stuff was to permit merging the types of arrays and functions. It seems a mistake to permit other than that. Are there reasons why this is permitted? Or is this accidental? : It is permitted to reject it also; in fact it may reject it even : if you try all the possibilities of char, unsigned, long, etc. instead : of int. The reasoning (theoretically) is that the compiler doesn't : have to announce in advance just which variety of int is compatible : with a particular enum. In effect, it is allowed to play the hostile : adversary, and choose a compatible integral type for this enum other than : the one you guessed! But it does! The standard says that which one it is compatible with is "implementation defined". That implies that it has to be documented. Furthermore, if we accept that the notion, stated in the Rationale, that "implementation defined" does not extend to failing to translate the program, applies here, then there has to be at least *one* declaration that will work. --- Bill {uunet|novavax}!proxftl!twwells!bill