[Bug c++/42862] New: Anonymous Structures: Incorrect DWARF data generated

louzonr at yahoo dot com gcc-bugzilla@gcc.gnu.org
Mon Jan 25 17:02:00 GMT 2010


GCC Version: 3.4.4 and 4.1.2

The GNU 4.1.2 C++ compiler is not generating the proper typedef DIEs in the
DWARF data.

For example, the type definition BASE_UNION is defined as

typedef union
{
   char ch;
   int iVal;
   long IVal;
} BASE_UNION;

The GNU 4.1.2 compiler generates the following DWARF data for this type

<1><1279>: Abbrev Number: 35 (DW_TAG_union_type)
   <127a>     DW_AT_sibling     : <12a8>    
   <127e>     DW_AT_name        : $_4    
   <1282>     DW_AT_byte_size   : 4    
   <1283>     DW_AT_decl_file   : 35    
   <1284>     DW_AT_decl_line   : 29    


<2><1285>: Abbrev Number: 36 (DW_TAG_member)
   <1286>     DW_AT_name        : ch    
   <1289>     DW_AT_decl_file   : 35    
   <128a>     DW_AT_decl_line   : 30    
   <128b>     DW_AT_type        : <c0d>    
<2><128f>: Abbrev Number: 36 (DW_TAG_member)
   <1290>     DW_AT_name        : iVal    
   <1295>     DW_AT_decl_file   : 35    
   <1296>     DW_AT_decl_line   : 31    
   <1297>     DW_AT_type        : <b7f>    
<2><129b>: Abbrev Number: 36 (DW_TAG_member)
   <129c>     DW_AT_name        : IVal    
   <12a1>     DW_AT_decl_file   : 35    
   <12a2>     DW_AT_decl_line   : 32    
   <12a3>     DW_AT_type        : <b86>    

Notice that the union name has been set to "$_4" in DIE <1279>.  The correct
DWARF data would have no name attribute for the union DIE <1279> and it would
have a type-def DIE which pointed to the union die such as:

<1><xxxx>: DW_TAG_typedef
          DW_AT_name        : BASE_UNION
          DW_AT_decl_line   : 26
          DW_AT_decl_column : 3
          DW_AT_decl_file   : 9
          DW_AT_type        : <0x1279>

Interestingly enough, the GNU 3.4.4 compiler generates the following DWARF data
from the same source code and this is also incomplete:

<1><11d0>: Abbrev Number: 27 (DW_TAG_union_type)
   DW_AT_sibling     : <123f>    
   DW_AT_name        : (indirect string, offset: 0x6e): BASE_UNION    
   DW_AT_byte_size   : 4    
   DW_AT_decl_file   : 3    
   DW_AT_decl_line   : 29


-- 
           Summary: Anonymous Structures: Incorrect DWARF data generated
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: louzonr at yahoo dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42862



More information about the Gcc-bugs mailing list