This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/81932] Template arguments of type unsigned generate incorrect debugging information
- From: "ryxi at stu dot xidian.edu.cn" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 24 Aug 2017 16:24:46 +0000
- Subject: [Bug c++/81932] Template arguments of type unsigned generate incorrect debugging information
- Auto-submitted: auto-generated
- References: <bug-81932-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81932
--- Comment #11 from Xi Ruoyao <ryxi at stu dot xidian.edu.cn> ---
(In reply to Martin Sebor from comment #10)
> Unless the exact format for non-type template arguments is specified in
> DWARF (I don't think it is) it seems that a more robust solution is to
> enhance GDB to be able to understand types with and without the suffix (and
> other equivalent forms).
>
> In the type system there is no difference between A<2>, A<2U>, or
> A<(unsigned int)2> and all three are emitted as the DW_AT_name by compilers
> for A<unsigned> instantiated with the value 2.
>
> But Jason is the DWARF expert so he should weigh in on this question.
DWARF 5 2.15(Identifier Names):
> Because the names of program objects described by DWARF are the names as
> they appear in the source program, implementations of language translators
> that use some form of mangled name (as do many implementations of C++)
> should use the unmangled form of the name in the DW_AT_name attribute...
And DWARF wiki <http://wiki.dwarfstd.org/index.php?title=Best_Practices>:
> For template instantiations, the DW_AT_name attribute should contain both
> the source language name of the object and the template parameters that
> distinguish one instantiation from another. The resulting string should
> be in the natural form for the language, and should have a canonical
> representation (i.e., different producers should generate the same
> representation). For C++, the string should match that produced by the
> *target platform's canonical demangler*; spaces should only be inserted
> where syntactically required by the compiler.
Here our canonical demangler should be c++filt. And c++filt produce names
with type suffix.