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

            Bug ID: 91411
           Summary: Extraneous size & location attributes for members in
                    DWARF
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tromey at gcc dot gnu.org
  Target Milestone: ---

Consider this test case:

struct x
{
  int a : 5;
  int b : 2;
};

struct x x;


Compile with -g -c and then examine the DWARF.

For x::a, I get:

 <2><28>: Abbrev Number: 3 (DW_TAG_member)
    <29>   DW_AT_name        : a
    <2b>   DW_AT_decl_file   : 1
    <2c>   DW_AT_decl_line   : 3
    <2d>   DW_AT_decl_column : 7
    <2e>   DW_AT_type        : <0x45>
    <32>   DW_AT_byte_size   : 4
    <33>   DW_AT_bit_size    : 5
    <34>   DW_AT_bit_offset  : 27
    <35>   DW_AT_data_member_location: 0


This has two minor bugs.

First, DWARF 5 section 5.7.6 ("Data Member Entries") says:

The member entry corresponding to a data member that is defined in a structure,
union or class may have either a DW_AT_data_member_location attribute or a
DW_AT_data_bit_offset attribute.

I think that is an exclusive "or", meaning that having both attributes
is incorrect.

Second, the same section says:

If the size of a data member is not the same as the size of the type given for
the
data member, the data member has either a DW_AT_byte_size or a
DW_AT_bit_size attribute whose integer constant value (see Section 2.19 on
page 55) is the amount of storage needed to hold the value of the data member.

Again, to me this indicates that GCC should only emit one of the two
attributes.

Reply via email to