public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15569] New: gdb picks wrong base class method
@ 2013-06-03 23:50 dje at google dot com
  2013-06-03 23:52 ` [Bug c++/15569] " dje at google dot com
  0 siblings, 1 reply; 2+ messages in thread
From: dje at google dot com @ 2013-06-03 23:50 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/15569] gdb picks wrong base class method
  2013-06-03 23:50 [Bug c++/15569] New: gdb picks wrong base class method dje at google dot com
@ 2013-06-03 23:52 ` dje at google dot com
  0 siblings, 0 replies; 2+ messages in thread
From: dje at google dot com @ 2013-06-03 23:52 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15569

--- Comment #1 from dje at google dot com ---
Oops.  The gdb session should be:

(gdb) start
...
(gdb) n
25        base2 *b2 = new base2;
(gdb) n
26        derived *d = new derived;
(gdb) n
27        return b1->foo (0) + b2->foo (0) + d->foo (0);
(gdb) pty d->foo(0)
double

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-06-03 23:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-03 23:50 [Bug c++/15569] New: gdb picks wrong base class method dje at google dot com
2013-06-03 23:52 ` [Bug c++/15569] " dje at google dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).