Eric Sosman said:
Eric Sosman said:
Can you cite the Standard section(s) supporting your claim?
[that the width of a bit-field is part of its type]
6.7.2.1p10:
A bit-field is interpreted as a signed or unsigned integer type
consisting of the specified number of bits.
... so the "type" is one of the signed or unsigned integers.
It comes down to whether "consisting of" binds more or less tightly
than "is interpreted as:"
bit-field is interpreted as (a signed or unsigned ... of
the specified number of bits) -> Rentsch
(bit-field is interpreted as a signed or unsigned ...)
consisting of the specified number of bits -> Nilsson
I note, with my eyebrow archly arched, the absence of any mention
of bit-field widths in the exposition of conversion ranks. ;-)
They aren't mentioned explicitly, but are relevant because of the
second list item in 6.3.1.1p1 (unsigned types are covered by another
item in the same list):
The rank of a signed integer type shall be greater than the
rank of any signed integer type with less precision.
For integer types, 'precision' and 'width' are related -- knowing
one determines the other. In case there is any doubt that the size
of a bit-field is its width, there is this sentence in 6.2.6.1p4:
Values stored in bit-fields consist of m bits, where m is
the size specified for the bit-field.
So the width of a bit-field definitely affects its conversion rank.
(FWIW, gcc agrees with Rentsch -- which only goes to show that
there are earnest people on both sides of the question.)
I suspect the confusion arises because the Standard sometimes
refers to the type of a bit-field to mean the declared type of
the bit-field member rather than the access type for the
corresponding bit-field object. For most identifiers the
declared type and the access type are the same, and when they are
not (as happens with some function parameters) it's important to
distinguish the two; unfortunately the Standard isn't always good
about distinguishing these clearly when talking about bit-fields.
Does anyone know of any compiler that gives a result different from
what gcc gives in this regard?