This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: wider-than-int enums broken in C++
On Thu, 24 Jul 2003 12:40:37 -0700, Geoff Keating <geoffk@geoffk.org> wrote:
>> From: Mark Mitchell <mark@codesourcery.com>
>> On Wed, 2003-07-23 at 23:50, Geoff Keating wrote:
>> > Jason Merrill <jason@redhat.com> writes:
>> >
>> > > 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.
>
> So at least the following is valid:
>
> enum {
> a, b, c, d, e
> } x;
>
> x = 7;
>
> because the bitfield must have at least 3 bits.
Precisely, so TYPE_PRECISION is 3.
Jason