# Extensions for nested template type parameters
Hi all,
In the DWARF 5 Standard (2.23 Template Parameters) it says
“A debugging information entry that represents a template instantiation
will contain child entries describing the actual template parameters.
The containing entry and each of its child entries reference a template
parameter entry in any circumstance where the template definition
referenced a formal template parameter.”
I could not find a specification in case a template type parameter is
passed to another template (nested templates). Consider the following
example:
~~~
template<typename T> struct t1 {
T n1;
};
template<typename T> struct t2 {
T m1;
t1<T> m2;
};
int main()
{
t2<int> v1;
return 0;
}
~~~
gcc currently provides the following DWARF for this:
~~~
0x0000005e: DW_TAG_member
DW_AT_name ("m1")
DW_AT_decl_file ("/tmp/nested_templates.cc")
DW_AT_decl_line (6)
DW_AT_decl_column (5)
DW_AT_type (0x0000004c "int")
DW_AT_data_member_location (0x00)
0x00000069: DW_TAG_member
DW_AT_name ("m2")
DW_AT_decl_file ("/tmp/nested_templates.cc")
DW_AT_decl_line (7)
DW_AT_decl_column (9)
DW_AT_type (0x0000002e "t1<int>")
DW_AT_data_member_location (0x04)
~~~
Based on the current specification, the type of m1 should reference
a template parameter entry. This is a bug in gcc which has already
been described [1]. llvm/clang attempted to fix this in PR [2].
Also for m2 we can see that there is no information that its type was
originally described by a template type parameter of t2. However,
there is no specification addressing this specific case in the DWARF
Standard.
Besides missing consumer support (e.g. GDB or LLDB), missing support for
nested templates was one further reason why the llvm PR [2] was rejected
by David Blaikie. I discussed this topic with him since I am working on
the enablement in GDB and submitted a patch series [3] to support template
type resolution based on the current DWARF specification. David Blaikie
asked me to submit a DWARF issue for this, since we could not come up with
a useful specification for the nested case (type of m2 in the example
above).
So my question is: Can you come up with a useful description of how we
could extend the DWARF Standard for nested template type parameters?
Kind Regards,
Christina
## References
[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57006
[2]: https://github.com/llvm/llvm-project/pull/127654
[3]: https://sourceware.org/pipermail/gdb-patches/2025-December/223619.html
Intel Deutschland GmbH
Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
--
Dwarf-discuss mailing list
[email protected]
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss