> 1. is easy, see patch below.  2. is much harder - we need to
> compute the bit-offset relative to the bitfield group start,
> thus in get_bit_range we do
>   /* Compute the adjustment to bitpos from the offset of the field
>      relative to the representative.  */
>   offset = size_diffop (DECL_FIELD_OFFSET (field),
>                         DECL_FIELD_OFFSET (repr));
>   bitoffset = (tree_low_cst (offset, 1) * BITS_PER_UNIT
>                + tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 1)
>                - tree_low_cst (DECL_FIELD_BIT_OFFSET (repr), 1));
> and we cannot generally assume offset is zero (well, maybe we could
> arrange that though, at least we could assert that for all fields
> in a bitfield group DECL_FIELD_OFFSET is the same?).

I'm skeptical.

> Any suggestion?  Apart from trying to make sure that offset will
> be zero by construction?  Or by simply not handling bitfields
> properly that start at a variable offset?

Computing the offset in stor-layout.c and storing it in DECL_INITIAL?

> The finish_bitfield_representative hunk implements the fix for 1.,
> the rest the proposed zero-by-construction solution for 2.


Eric Botcazou

Reply via email to