The C FE (unlike C++) generates extra DW_TAG_variable in the debug info for e.g. extern int v; __typeof (v) v; or extern int v; __typeof (v) w; int v = 456; or extern int v; int foo (void) { return v; } int v;
The first one gives with -g -dA: .uleb128 0x2 # (DIE (0x2d) DW_TAG_variable) .ascii "v\0" # DW_AT_name .byte 0x1 # DW_AT_decl_file (u.c) .byte 0x1 # DW_AT_decl_line .long 0x38 # DW_AT_type .byte 0x1 # DW_AT_external .byte 0x1 # DW_AT_declaration .uleb128 0x3 # (DIE (0x38) DW_TAG_base_type) .byte 0x4 # DW_AT_byte_size .byte 0x5 # DW_AT_encoding .ascii "int\0" # DW_AT_name .uleb128 0x4 # (DIE (0x3f) DW_TAG_variable) .ascii "v\0" # DW_AT_name .byte 0x1 # DW_AT_decl_file (u.c) .byte 0x2 # DW_AT_decl_line .long 0x38 # DW_AT_type .byte 0x1 # DW_AT_external .byte 0x9 # DW_AT_location .byte 0x3 # DW_OP_addr .quad v The first decl is olddecl from merge_decls, while the second one is newdecl from it (from the last one of them). -- Summary: Useless DW_TAG_variable generated Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45020