This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Help with bit-field semantics in C and C++
- From: Roger Sayle <roger at eyesopen dot com>
- To: Geoff Keating <geoffk at geoffk dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 24 Aug 2004 15:39:35 -0600 (MDT)
- Subject: Re: Help with bit-field semantics in C and C++
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
--