This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/22013] Default value in template argument list breaks RTTI lookup
- From: "jwakely.gcc at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Mon, 05 Feb 2018 13:09:47 +0000
- Subject: [Bug c++/22013] Default value in template argument list breaks RTTI lookup
- Auto-submitted: auto-generated
- References: <bug-22013-4717@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=22013
Jonathan Wakely <jwakely.gcc at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jwakely.gcc at gmail dot com
--- Comment #3 from Jonathan Wakely <jwakely.gcc at gmail dot com> ---
Reduced example:
template<typename>
struct PolymorphicType
{
virtual ~PolymorphicType() {}
int value;
};
template <typename, int = 1000>
struct ATemplate
{
struct NestedType { };
};
int main()
{
auto poly = new PolymorphicType<ATemplate<long>::NestedType>();
return poly->value;
}
$ g++ -ggdb3 test.cc -Wall -Wextra
$ gdb -q -ex start -ex n -ex n -ex "p poly.value" \
-ex 'python print(str(gdb.parse_and_eval("poly").type.target()))' \
a.out
Reading symbols from a.out...done.
Temporary breakpoint 1 at 0x400620: file test.cc, line 17.
Starting program: /tmp/a.out
Temporary breakpoint 1, main () at test.cc:17
17 auto poly = new PolymorphicType<ATemplate<long>::NestedType>();
19 return poly->value;
20 }
warning: RTTI symbol not found for class 'PolymorphicType<ATemplate<long,
1000>::NestedType>'
$1 = 0
PolymorphicType<ATemplate<long>::NestedType>
(gdb)
An example using a C++17 "template<auto>" type shows a similar problem, GDB
looks for RTTI for AutoTemplate<1u> but the typename is AutoTemplate<1> (which
is arguably a GCC bug, see https://gcc.gnu.org/ml/gcc/2018-02/msg00026.html):
template<typename>
struct PolymorphicType
{
virtual ~PolymorphicType() {}
int value;
};
template <auto>
struct AutoTemplate
{
};
int main()
{
auto poly = new PolymorphicType<AutoTemplate<1u>>();
return poly->value;
}
$ g++ -ggdb3 -std=c++17 auto.cc -Wall -Wextra
$ gdb -q -ex start -ex n -ex n -ex "p poly.value" \
-ex 'python print(str(gdb.parse_and_eval("poly").type.target()))' \
a.out
Reading symbols from a.out...done.
Temporary breakpoint 1 at 0x400620: file auto.cc, line 16.
Starting program: /tmp/a.out
Temporary breakpoint 1, main () at auto.cc:16
16 auto poly = new PolymorphicType<AutoTemplate<1u>>();
18 return poly->value;
19 }
warning: RTTI symbol not found for class 'PolymorphicType<AutoTemplate<1u> >'
$1 = 0
PolymorphicType<AutoTemplate<1> >
(gdb)
--
You are receiving this mail because:
You are on the CC list for the bug.