When debugging a program built with gcc-2.95.2 on a Sparc/Solaris 2.6
machine and accessing a virtual function, I get:
    Cannot resolve method C::a to any overloaded instance

A very simple testcase follows.  Here's the gdb banner:

GNU gdb 4.18
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.6"...



Here's the transcript of the gdb session:

(gdb) info br
Num Type           Disp Enb Address    What
1   breakpoint     keep y   0x00029b34 in B::a(void) at test.cc:11
(gdb) run
Breakpoint 1, B::a (this=0xffbef520) at test.cc:11
11          virtual void a() { cout << "B::a()" << endl; }
(gdb) up 2
#2  0x1ab8c in main () at test.cc:31
31          trythis(b);
(gdb) p c.a()
Cannot resolve method C::a to any overloaded instance



Here's the testcase:
#include <iostream>

struct A 
{
    virtual void a() = 0;
};


struct B : A
{
    virtual void a() { cout << "B::a()" << endl; }
};

struct C : A
{
    virtual void a() { cout << "C::a()" << endl; }
};


void trythis(A& a)
{
    a.a();
}


main()
{
    B b;
    C c;

    trythis(b);
    trythis(c);
}

Reply via email to