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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2017-01-11
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 40505
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40505&action=edit
gcc7-pr78839.patch

There were actually numerous bugs in that commit in the field_byte_offset
routine.  is_bit_offset_cst and is_byte_offset_cst vars were set to values that
is the opposite of their names, then the whole PCC_BITFIELD_TYPE_MATTERS block
was actually never entered, because there was:
  if (is_bit_offset_cst)
    return NULL;

#ifdef PCC_BITFIELD_TYPE_MATTERS
  /* We used to handle only constant offsets in all cases.  Now, we handle
     properly dynamic byte offsets only when PCC bitfield type doesn't
     matter.  */
  if (PCC_BITFIELD_TYPE_MATTERS && is_byte_offset_cst && is_bit_offset_cst)

and after the first if is_bit_offset_cst thus was always false.  But even with
that fixed, the whole block computed something that has been just ignored.

So, let's fix this first, then as incremental separately tested patch also use
DECL_BIT_FIELD_REPRESENTATIVE if possible, and lastly for DWARF-4 and later we
actually shouldn't be emitting for bitfields DW_AT_data_member_location and
DW_AT_byte_size and DW_AT_bit_offset attributes at all, we should emit
DW_AT_data_bit_offset (PR71669) instead of those.  As GDB just gained
DW_AT_data_bit_offset support last November, I'll for now use it only for
-gdwarf-5 (which requires latest GDB anyway).

Reply via email to