This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix for short-enums comparison bug
- To: law at cygnus dot com
- Subject: Re: [PATCH] Fix for short-enums comparison bug
- From: Gavin Romig-Koch <gavin at cygnus dot com>
- Date: Thu, 11 Feb 1999 14:35:41 -0500 (EST)
- Cc: Gavin Romig-Koch <gavin at cygnus dot com>, Charles G Waldman <cgw at alum dot mit dot edu>, egcs at egcs dot cygnus dot com
- References: <14018.60839.325601.426391@cetus.cygnus.com><5858.918754318@hurl.cygnus.com>
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...