This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/15569] New: gdb picks wrong base class method
- From: "dje at google dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Mon, 03 Jun 2013 23:50:33 +0000
- Subject: [Bug c++/15569] New: gdb picks wrong base class method
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=15569
Bug ID: 15569
Summary: gdb picks wrong base class method
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: c++
Assignee: unassigned at sourceware dot org
Reporter: dje at google dot com
gdb is calling base2::foo in "p d->foo (0)" even though it should be calling
base1::foo.
After some experimentation, it's apparently because base2 appears after base1
in the inheritance list; although AIUI the order there should be irrelevant for
lookup.
[Note: gcc has a bug where it emits the "using" statement
(DW_TAG_imported_declaration) in the base class, not the derived class.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57519
Fixing that is arguably a prerequisite for fixing this.]
[I couldn't find an existing bug for this ... at least I looked. :-)]
class base1
{
public:
int foo (int x) { return x; }
};
class base2
{
public:
double foo (double x) { return x; }
};
class derived : base1, base2
{
public:
using base1::foo;
//using base2::foo;
};
int
main ()
{
base1 *b1 = new base1;
base2 *b2 = new base2;
derived *d = new derived;
return b1->foo (0) + b2->foo (0) + d->foo (0);
}
(gdb) start
(gdb) pty d->foo(0)
double
--
You are receiving this mail because:
You are on the CC list for the bug.