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++


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?

enum {
  a,
  b,
  c
} x;

x = 20;

is valid?


-- 
- Geoffrey Keating <geoffk@geoffk.org>


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