This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/20185] New: RTTI symbol not found for nested virtual class


https://sourceware.org/bugzilla/show_bug.cgi?id=20185

            Bug ID: 20185
           Summary: RTTI symbol not found for nested virtual class
           Product: gdb
           Version: 7.10
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: scovich at gmail dot com
  Target Milestone: ---

Consider the following multi-file toy program:

=== bug-bar.h =======
struct Foo {
   virtual ~Foo() { }
   virtual void foo()=0;
};

struct Bar {
   struct BarFoo : Foo {
      virtual void foo() { }
   };
   static Foo* getFoo();
};
=====================

=== bug-bar.cpp =====
#include "bug-bar.h"

Foo* Bar::getFoo() { return new BarFoo; }
=====================

=== bug.cpp =========
#include "bug-bar.h"
int main() {
    Foo* f = Bar::getFoo();
    f->foo();
}
=====================

The following steps show gdb is unable to find the RTTI info for the nested
virtual class BarFoo:

$ g++ -g -Wall -c scratch.cpp
$ g++ -g -Wall -c scratch-bar.cpp
$ g++ -g -Wall scratch.o scratch-bar.o
$ gdb a.out
Reading symbols from a.out...done.
(gdb) set print object
(gdb) start
(gdb) start
Temporary breakpoint 1 at 0x4007d5: file scratch.cpp, line 4.
Starting program: /home/ryan/experiments/a.out
Temporary breakpoint 1, main () at scratch.cpp:4
(gdb) next
(gdb) p f
$1 = (warning: RTTI symbol not found for class 'Bar::BarFoo'
warning: RTTI symbol not found for class 'Bar::BarFoo'
Foo *) 0x603010
(gdb) p f->foo()
warning: RTTI symbol not found for class 'Bar::BarFoo'
warning: RTTI symbol not found for class 'Bar::BarFoo'
warning: RTTI symbol not found for class 'Bar::BarFoo'
$2 = void


The problem goes away if I compile all three .cpp directly into a.out, or if
BarFoo is declared as a stand-alone class. It does not seem to matter where the
virtual functions are declared.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]