https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109039

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think the bug is in class.cc (end_of_class), which does:
        offset = size_binop (PLUS_EXPR, byte_position (field), size);
That works fine for non bit-fields, but for bit-fields it is sometimes
incorrect.
In particular, X::x1 has DECL_SIZE 8, DECL_SIZE_UNIT 1, DECL_FIELD_OFFSET 0,
DECL_FIELD_BIT_OFFSET 7.  So, byte_position (field) is still 0, and size 1,
therefore offset is set to 1, even when the bit-field occupies just 1 bit in
the first
byte and 7 in the second byte, so I think we want to set offset to 2 in this
case.

The Itanium ABI says:
In either case, update dsize(C) to include the last byte containing (part of)
the bit-field, and update sizeof(C) to max(sizeof(C),dsize(C)). 
So, I think for bit-fields we instead want to sum bit_position (field) and
DECL_SIZE and CEIL_DIV_EXPR it by bitsize_unit_node and cast to sizetype.

Reply via email to