Help with bit-field semantics in C and C++

Roger Sayle roger@eyesopen.com
Tue Aug 24 22:22:00 GMT 2004


On Tue, 24 Aug 2004, Geoff Keating wrote:
> It's interesting that you mention bitfields.  I believe that's a case
> where the mode's bitsize is not the same as the precision of the
> bitfield's type, but the bitfield must be sign- or zero- extended.

The problem is that these values are neither sign nor zero extended.
We currently can't rely on the bits beyond the type's precision but
below the type's mode's bitsize being copies of the sign-bit, indeed
we can't even guarantee that all such bits are the same.

There's a PR where fold optimizes "x & signbit" into "x < 0" which
unfortunately doesn't hold C++ enumerated types.  Indeed it isn't
clear whether signed vs. unsigned type distinction makes much sense
for these "paradoxical" types (terminology implied by RTL SUBREGs).

Roger
--



More information about the Gcc mailing list