Topic: Enum values (was incomplete enum)
Author: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes)
Date: Tue, 21 Feb 1995 13:04:56 GMT Raw View
Steve Clamage (clamage@Eng.Sun.COM) wrote:
: ti953017@rzcipa01.rz.tu-bs.de (Andreas Rossberg) writes:
: enum error_type { info=0, reminder=3000, warning=6000, error=9000 };
: This will allow up to 3000 enumerators for each type of message, and
: you can have a largest enumerator of 16383, guaranteed by the C++ rules.
: (16383 requires no more bits than 9000, but 16384 does.) Notice that
: this example has an implied minimum of 0 and implied maximum of 16383.
: This enum type can be extended at will in implementation files
: without requiring recompilation of any code which does not use
: the new enumerations.
Can you confirm that you are implying that a variable of type error_type
can be used to safely store the value 16383 (in fact any value up to and
including that). My understanding (based on C rather than C++) was that
you could not safely store any values other than the listed enumeration
values. The compiler is a liberty to assume that the variable is only
used for the specified values. For example:
error_type err;
if( err == 123 )... /* compiler can assume this is always false
as 123 is not in error_type */
--
Stephen Baynes baynes@mulsoc2.serigate.philips.nl
Philips Semicondutors Ltd
Southampton My views are my own.
United Kingdom