This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: G++ enums 'underlying type'
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Paul Schlie <schlie at comcast dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 25 Dec 2004 22:07:49 +0100
- Subject: Re: G++ enums 'underlying type'
- References: <BDF33EB6.8609%schlie@comcast.net>
Paul Schlie wrote:
To my understanding, C enums need only be represented as the smallest rank
signed or unsigned integer type capable of representing it's value range
(although GCC tends to first unnecessarily promote enums to int, which I
believe is officially the largest enum equivalent type, and then back them
down opportunistically; keeping their converted form as small as possible is
significant to small machine targets, so they should not be unnecessarily
represented as being any larger than necessary, just as bool/char/short
types should not be needlessly promoted).
Ok, thanks, makes sense. Didn't know about the "back them down
oppurtinistically"
thing, which indeed is allowed by the standard and useful. For now, I
will just keep
the code as-is, catching any possible integral type.
Paolo.