Discussion:
[Bug c++/19320] New: RTTI symbols not found for non-type templates
scovich at gmail dot com
2015-12-01 13:39:36 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=19320

Bug ID: 19320
Summary: RTTI symbols not found for non-type templates
Product: gdb
Version: 7.10
Status: NEW
Severity: normal
Priority: P2
Component: c++
Assignee: unassigned at sourceware dot org
Reporter: scovich at gmail dot com
Target Milestone: ---

Consider the following simple test case:

=== bug.cpp ==========
struct Base {
virtual ~Base() { }
virtual int getN()=0;
};
template <char N>
struct Child : Base {
virtual int getN() { return N; };
};
int main() {
Base *b = new Child<5>;
return b->getN();
}
======================

Then the following cleaned-up typescript illustrates the problem:
=== typescript ========
$ g++ -g bug.cpp
$ gdb a.out
GNU gdb (GDB) 7.8
Copyright (C) 2014 Free Software Foundation, Inc.
...
(gdb) b bug.cpp:11
Breakpoint 1 at 0x1004010ee: file bug.cpp, line 11.
(gdb) r
`/tmp/a.out' has changed; re-reading symbols.
Starting program: /tmp/a.out

Breakpoint 1, main () at bug.cpp:11
(gdb) set print object
(gdb) p *b
warning: RTTI symbol not found for class 'Child<(char)5>'
$1 = warning: RTTI symbol not found for class 'Child<(char)5>'
warning: RTTI symbol not found for class 'Child<(char)5>'
{_vptr.Base = 0x1004030f0 <vtable for Child<(char)5>+16>}
(gdb) whatis foo::Child^I^I
foo::Child<(char)foo::Child<(char)'\005'>
foo::Child<(char)foo::Child<(char)5>::Child()
foo::Child<(char)foo::Child<(char)5>::getN()
foo::Child<(char)foo::Child<(char)5>::~Child()
=======================

Changing the template parameter type to `unsigned char` produces:
(gdb) p *b
(gdb) p *b
warning: RTTI symbol not found for class 'Child<(unsigned char)5>'
$4 = warning: RTTI symbol not found for class 'Child<(unsigned char)5>'
warning: RTTI symbol not found for class 'Child<(unsigned char)5>'
{_vptr.Base = 0x1004030f0 <vtable for Child<(unsigned char)5>+16>}
(gdb) whatis Child<^I^I
Child<5u>
Child<(unsigned char)5>::Child()
Child<(unsigned char)5>::getN()
Child<(unsigned char)5>::~Child()

Changing to an enum produces:

Changing to a bare `int` produces the desired behavior:
(gdb) p *b
$2 = (Child<5>) {<Base> = {
_vptr.Base = 0x1004030f0 <vtable for Child<5>+16>}, <No data fields>}


As does a bare `unsigned int`:
(gdb) p *b
$3 = (Child<5u>) {<Base> = {
_vptr.Base = 0x1004030f0 <vtable for Child<5u>+16>}, <No data fields>}

As does an enum `foo`:
(gdb) p *b
$5 = (Child<(foo)5>) {<Base> = {
_vptr.Base = 0x1004030f0 <vtable for Child<(foo)5>+16>}, <No data fields>}


The type names given for members of of such a template class do seem to be
represented consistently.
--
You are receiving this mail because:
You are on the CC list for the bug.
weimin.pan at oracle dot com
2018-05-21 21:17:59 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=19320

weimin.pan at oracle dot com changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |weimin.pan at oracle dot com

--- Comment #1 from weimin.pan at oracle dot com ---
The warning was issued when no type could be found in
gnuv3_rtti_type(), using the class name in the vtable
entry:

The vtable's demangled name:

_ZTV5ChildILc5EE == vtable for Child<(char)5>

with class name == Child<(char)5>

But the dwarf info generated for the struct:

<1><29>: Abbrev Number: 2 (DW_TAG_structure_type)
<2a> DW_AT_name : (indirect string, offset: 0x7f): Child<'\005'>
<2e> DW_AT_byte_size : 8
<2f> DW_AT_decl_file : 1
<30> DW_AT_decl_line : 6
<31> DW_AT_containing_type: <0xb5>
<35> DW_AT_sibling : <0xb5>

in which the name looks incorrect.
--
You are receiving this mail because:
You are on the CC list for the bug.
simon.marchi at ericsson dot com
2018-05-22 03:40:58 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=19320

Simon Marchi <simon.marchi at ericsson dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |simon.marchi at ericsson dot com

--- Comment #2 from Simon Marchi <simon.marchi at ericsson dot com> ---
I think it falls under this umbrella:

https://gcc.gnu.org/ml/gcc/2018-02/msg00009.html
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...