bitfield signedness

Wouter Vermaelen wouter.vermaelen@scarlet.be
Sat Apr 30 05:08:00 GMT 2011


On 04/29/2011 09:37 PM, Kalle Olavi Niemitalo wrote:
> Wouter Vermaelen<wouter.vermaelen@scarlet.be>  writes:
>
> In s.a<  -1, the<  operator performs (C99 6.5.8p3) the usual
> arithmetic conversions, which include (6.3.1.8p1) the integer
> promotions (6.3.1.1p2).  In unsigned a : 27, the width of the
> bit-field is part of the type (6.7.2.1p9).  If the int type is
> 32-bit as usual, then all possible values of s.a fit in int, and
> the result of the integer promotions is an int, even though the
> bit-field was declared as unsigned.
>
> I don't know if C89 had different rules for this.
>
> An extended C++ variant of your test program:
 >
 > ....

Thanks for your detailed answer. Also thanks for your test
program, that typeid() trick is very useful.

Wouter



More information about the Gcc-help mailing list