This is the mail archive of the egcs@egcs.cygnus.com mailing list for the EGCS project. See the EGCS home page for more information.
Jeffrey A Law writes:
> Yes the underlying type must be capable of representing all the values for
> the enum. But does the enum restrict the actual values which can be used
> with the expected results?
The enum can restrict the actual values which can be used to the values
of the choosen underlying type. The underlying type must be an existing
type (the compiler can't make up a new "tiny" type for the underlying
type). If you know the underlying type, you know what values can be
used.
> My quick read of the C++ standard made it appear as if assigning a value that
> was not a member of the enum resulted in undefined results. Is this possibly a
> case where C++ and C differ?
Probably. There was talk in the C++ committee to restrict the usable
values farther than C does, but I don't remember the outcome of that
discussion. c9x kept the old C rules.
-gavin...