This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: wider-than-int enums broken in C++


On Wed, 2003-07-23 at 23:50, Geoff Keating wrote:
> Jason Merrill <jason@redhat.com> writes:
> 
> > On 23 Jul 2003 23:50:15 -0300, Alexandre Oliva <aoliva@redhat.com> wrote:
> > 
> > > Your patch for PR 10796, that implemented C++ DR377, also contained a
> > > code clean-up that was actually wrong.  The underlying type of an enum
> > > must be an integral type, but, after your patch, we end up with a type
> > > whose precision is given by the min and max values of the enumeration,
> > > that doesn't necessarily match the precision of any of the integral
> > > types.
> > 
> > How did this break the testcase?  I thought the point of TYPE_PRECISION was
> > to describe the expressible values.  We set TYPE_PRECISION to 1 for bool
> > even though we allocate more than one bit for it.
> 
> But, for enums, you can express any value that fits in the type, correct?

Not in C++.

  For  an  enumeration where emin is the smallest enumerator and emax is
  the largest, the values of the  enumeration  are  the  values  of  the
  underlying  type  in  the range bmin to bmax, where bmin and bmax are,
  respectively, the smallest and largest values  of  the  smallest  bit-
  field that can store emin and emax.

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]