[Bug ada/83935] New: DWARF for a variant part is incorrect
tromey at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 18 21:41:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83935
Bug ID: 83935
Summary: DWARF for a variant part is incorrect
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: tromey at gcc dot gnu.org
Target Milestone: ---
Joel Brobecker sent me an Ada test case so that I could see a real-life
example of the use of DW_TAG_variant_part (in support of some Rust
stuff I'm doing elsewhere).
For this test case, GCC emits this DWARF:
<1><7c0>: Abbrev Number: 4 (DW_TAG_structure_type)
<7c1> DW_AT_name : (indirect string, offset: 0xb26): pck__rec
<7c5> DW_AT_byte_size : 13 byte block: 97 94 1 99 95 0 0 0 23 7 9 fc 1a
<7d3> DW_AT_decl_file : 2
<7d4> DW_AT_decl_line : 15
<7d5> DW_AT_sibling : <0x817>
<2><7d9>: Abbrev Number: 5 (DW_TAG_member)
<7da> DW_AT_name : (indirect string, offset: 0xaf8): discr
<7de> DW_AT_decl_file : 2
<7df> DW_AT_decl_line : 15
<7e0> DW_AT_type : <0x7af>
<7e4> DW_AT_data_member_location: 0
<2><7e5>: Abbrev Number: 6 (DW_TAG_variant_part)
<7e6> DW_AT_discr : <0x7d9>
<3><7ea>: Abbrev Number: 7 (DW_TAG_variant)
<7eb> DW_AT_discr_value : 1
<7ec> DW_AT_sibling : <0x7fd>
However, the DWARF standard says:
> If the variant part has a discriminant, the discriminant is represented
> by a separate debugging information entry which is a child of the variant part entry.
So, I think that, according to the DWARF standard, that "discr" member must be
a child (not a sibling) of the DW_TAG_variant_part.
More information about the Gcc-bugs
mailing list