Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!utoday!comeau From: comeau@utoday.UUCP (Greg Comeau) Newsgroups: comp.lang.c++ Subject: Re: const enums -- Lawyers opinions?? Keywords: const, enum Message-ID: <1142@utoday.UUCP> Date: 10 Jan 90 16:59:04 GMT References: <963@rna.UUCP> <10197@microsoft.UUCP> <9925@ardent.UUCP> Reply-To: comeau@.UUCP (Greg Comeau) Organization: UNIX Today!, Manhasset, NY Lines: 28 In article <9925@ardent.UUCP> jss@jra.ardent.com () writes: >In article <10197@microsoft.UUCP> jimad@microsoft.UUCP (JAMES ADCOCK) writes: >>cfront 2.0 accepts this with the appropriate warning that you're assigning >>an int to an enum -- when you or individual bits together you end up with >>values not in the set original defined in the bits enum -- so how can the > >The question of what an enum type "really is", ...a consensus finally >emerged and both ANSI C and the most recent C++ reference manual agree >that they are integral types. This means that its perfectly sensible to >assign arbitrary integer values to variables of enum type. > >Jerry Schwarz Although I agree that enum's are now integral types in both dpANSI C and C++ one must take the semantics of enums into consideration before saying that they (integrals) are completely convertable amongst each other. First although enums contain integer constant values (int's actually), they are not an integer types (a basic type accto ANSI) per se. Also, although ANSI C makes no mandation as I recall, in C++ enums are actually types and therefore although the enumerators values are convertable to int values, only enumerator values are supposed to be assigned to objects of the respective enumeration (in other words these is no implicit integral promotion or conversion when going into an enum lvalue). -- Greg, Comeau Computing, 91-34 120th Street, Richmond Hill, NY, 11418 Also, mag writer for UNIX Today! (SysAdm columnist), Microsoft Systems Journal (C programming), + others. Also, BIX c.language & c.plus.plus conf. moderator. Here:attmail!csanta!greg / BIX:comeau / CIS:72331, 3421 / voice:718-849-2355