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: Joe Buck <jbuck at Synopsys dot COM>
- Date: Thu, 11 Feb 99 17:02:07 PST
- Cc: tim at wagner dot Princeton dot EDU, jbuck at Synopsys dot COM, gavin at cygnus dot com, cgw at alum dot mit dot edu, egcs at egcs dot cygnus dot com
> In message <199902112216.RAA27319@wagner.Princeton.EDU>you write:
> > I seriously doubt it, since arguments to integer operators undergo
> > integral promotion. The rules are different for C++, but I believe
> > the answer is no, since none of the standard integral types is allowed
> > to have only 2 bits.
> I'm not looking for "I doubt/I believe". I need folks to actually check the
> relavent standard and say "The standard ..." :-)
The relevant part of the C++ standard has the label "dcl.enum": look
for .../dcl.html#dcl.enum in your favorite copy of the standard (I
assume you have an up-to-date version inside Cygnus).
I'm currently looking at the Dec. 96 draft, so I don't know if there were
changes made later (you can check your local copy). Two things are
described: the legal integral values that can be assigned to the enum, and
the "underlying type", which is implementation-dependent but can't be
larger than int unless there are enum values that don't fit in int or
unsigned int.
Stroustrup "The C++ Programming Language, Third Edition"'s section 4.8 may
be a clearer explanation of what is intended (though of course it is
non-normative).