https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80466
Bug ID: 80466
Summary: template<> using loses template argument in debuginfo
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
Assignee: unassigned at gcc dot gnu.org
Reporter: b.r.longbons at gmail dot com
Target Milestone: ---
// BAD: g++-6 -std=c++0x -g using-template.cpp -o using-template -gdwarf-4
// BAD: g++-6 -std=c++0x -g using-template.cpp -o using-template -gdwarf-5
// BAD: g++-7 -std=c++0x -g using-template.cpp -o using-template -gdwarf-4
// ?BAD?: g++-7 -std=c++0x -g using-template.cpp -o using-template
-gdwarf-5
// (My `readelf` and `dwarfdump` both barf on the last, but `strings -n 3`
looks like there's no change)
// An example speaks louder than words for this sort of thing:
template<class T>
class qux
{
};
template<class T>
using foo = qux<T>;
qux<int> works_int;
foo<int> fails_int;
qux<void> works_void;
foo<void> fails_void;
int main()
{
}
/*
readelf -wi using-template
Contents of the .debug_info section:
Compilation Unit @ offset 0x0:
Length: 0xdc (32-bit)
Version: 4
Abbrev Offset: 0x0
Pointer Size: 8
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
<c> DW_AT_producer : (indirect string, offset: 0x38): GNU C++11 7.0.1
20170407 (experimental) [trunk revision 246759] -mtune=generic -march=x86-64 -g
-gdwarf-4 -std=c++11
<10> DW_AT_language : 4 (C++)
<11> DW_AT_name : (indirect string, offset: 0x0):
using-template.cpp
<15> DW_AT_comp_dir : (indirect string, offset: 0x26): /tmp/dl
<19> DW_AT_low_pc : 0x61a
<21> DW_AT_high_pc : 0xb
<29> DW_AT_stmt_list : 0x0
<1><2d>: Abbrev Number: 2 (DW_TAG_class_type)
<2e> DW_AT_name : (indirect string, offset: 0x13): qux<int>
<32> DW_AT_byte_size : 1
<33> DW_AT_decl_file : 1
<34> DW_AT_decl_line : 2
<35> DW_AT_sibling : <0x41>
<2><39>: Abbrev Number: 3 (DW_TAG_template_type_param)
<3a> DW_AT_name : T
<3c> DW_AT_type : <0xd8>
<2><40>: Abbrev Number: 0
<1><41>: Abbrev Number: 4 (DW_TAG_variable)
<42> DW_AT_name : (indirect string, offset: 0x1c): works_int
<46> DW_AT_decl_file : 1
<47> DW_AT_decl_line : 9
<48> DW_AT_type : <0x2d>
<4c> DW_AT_external : 1
<4c> DW_AT_location : 9 byte block: 3 29 10 20 0 0 0 0 0
(DW_OP_addr: 201029)
<1><56>: Abbrev Number: 5 (DW_TAG_typedef)
<57> DW_AT_name : foo
<5b> DW_AT_decl_file : 1
<5c> DW_AT_decl_line : 7
<5d> DW_AT_type : <0x2d>
<1><61>: Abbrev Number: 4 (DW_TAG_variable)
<62> DW_AT_name : (indirect string, offset: 0xb2): fails_int
<66> DW_AT_decl_file : 1
<67> DW_AT_decl_line : 10
<68> DW_AT_type : <0x56>
<6c> DW_AT_external : 1
<6c> DW_AT_location : 9 byte block: 3 2a 10 20 0 0 0 0 0
(DW_OP_addr: 20102a)
<1><76>: Abbrev Number: 2 (DW_TAG_class_type)
<77> DW_AT_name : (indirect string, offset: 0x2e): qux<void>
<7b> DW_AT_byte_size : 1
<7c> DW_AT_decl_file : 1
<7d> DW_AT_decl_line : 2
<7e> DW_AT_sibling : <0x86>
<2><82>: Abbrev Number: 6 (DW_TAG_template_type_param)
<83> DW_AT_name : T
<2><85>: Abbrev Number: 0
<1><86>: Abbrev Number: 4 (DW_TAG_variable)
<87> DW_AT_name : (indirect string, offset: 0xbc): works_void
<8b> DW_AT_decl_file : 1
<8c> DW_AT_decl_line : 12
<8d> DW_AT_type : <0x76>
<91> DW_AT_external : 1
<91> DW_AT_location : 9 byte block: 3 2b 10 20 0 0 0 0 0
(DW_OP_addr: 20102b)
<1><9b>: Abbrev Number: 5 (DW_TAG_typedef)
<9c> DW_AT_name : foo
<a0> DW_AT_decl_file : 1
<a1> DW_AT_decl_line : 7
<a2> DW_AT_type : <0x76>
<1><a6>: Abbrev Number: 4 (DW_TAG_variable)
<a7> DW_AT_name : (indirect string, offset: 0xc7): fails_void
<ab> DW_AT_decl_file : 1
<ac> DW_AT_decl_line : 13
<ad> DW_AT_type : <0x9b>
<b1> DW_AT_external : 1
<b1> DW_AT_location : 9 byte block: 3 2c 10 20 0 0 0 0 0
(DW_OP_addr: 20102c)
<1><bb>: Abbrev Number: 7 (DW_TAG_subprogram)
<bc> DW_AT_external : 1
<bc> DW_AT_name : (indirect string, offset: 0xad): main
<c0> DW_AT_decl_file : 1
<c1> DW_AT_decl_line : 15
<c2> DW_AT_type : <0xd8>
<c6> DW_AT_low_pc : 0x61a
<ce> DW_AT_high_pc : 0xb
<d6> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<d8> DW_AT_GNU_all_call_sites: 1
<1><d8>: Abbrev Number: 8 (DW_TAG_base_type)
<d9> DW_AT_byte_size : 4
<da> DW_AT_encoding : 5 (signed)
<db> DW_AT_name : int
<1><df>: Abbrev Number: 0
*/
// In particular, note the identical DW_AT_name of each DW_TAG_typedef.