This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82724] New: Larger than needed DWARF type declarations for explicitly instantiated class templates
- From: "dblaikie at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 25 Oct 2017 22:23:05 +0000
- Subject: [Bug c++/82724] New: Larger than needed DWARF type declarations for explicitly instantiated class templates
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82724
Bug ID: 82724
Summary: Larger than needed DWARF type declarations for
explicitly instantiated class templates
Product: gcc
Version: 6.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: dblaikie at gmail dot com
Target Milestone: ---
When the vtable/key function debug info optimization kicks in, a declaration
(rather than a definition) of a type is produced:
$ cat foo.cpp
template <typename T> struct foo {
T t;
virtual ~foo() {}
};
extern template struct foo<int>;
foo<int> *f;
$ g++-6.3 foo.cpp -g -c && llvm-dwarfdump-tot foo.o | grep
"DW_TAG\|DW_AT_name\|DW_AT_declaration"
...
DW_TAG_structure_type
DW_AT_name ("foo<int>")
DW_AT_declaration (true)
DW_TAG_template_type_parameter
DW_AT_name ("T")
...
But if the class template is only a declaration, then the DWARF is smaller -
the template_type_parameter is omitted (& thus anything that actual type
description and anything that type references is also omitted):
$ cat foo.cpp
template <typename T> struct foo;
foo<int> *f;
$ g++-6.3 foo.cpp -g -c && llvm-dwarfdump-tot foo.o | grep
"DW_TAG\|DW_AT_name\|DW_AT_declaration"
...
DW_TAG_structure_type
DW_AT_name ("foo<int>")
DW_AT_declaration (true)
...
This seems more compact and GDB knows how to cope with it, since it's been this
way forever - so it probably makes sense to make the declaration in the first
case look like the declaration in the second case so it's more compact.
LLVM/Clang already does this.