This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/8117: Ambiguous base for multiple inheritance with pure virtual base
- From: yuvalk at mainsoft dot com
- To: gcc-gnats at gcc dot gnu dot org
- Cc: yuvalk at mainsoft dot com, kostat at mainsoft dot com, jluu at mainsoft dot com
- Date: Wed, 2 Oct 2002 10:45:43 +0300
- Subject: c++/8117: Ambiguous base for multiple inheritance with pure virtual base
- Reply-to: yuvalk at mainsoft dot com
>Number: 8117
>Category: c++
>Synopsis: Ambiguous base for multiple inheritance with pure virtual base
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Wed Oct 02 00:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Yuval Kfir
>Release: 3.2
>Organization:
Mainsoft Co. Ltd.
>Environment:
System: Linux twins 2.4.18-3custom #1 SMP Thu Sep 19 12:30:28 IDT 2002 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.2/configure --prefix=/usr/gcc/3.2 --enable-languages=c,c++
>Description:
I have a class D which inherits B, C, both of which inherit A. All classes
except D contain only pure virtual functions, and D provides the implementation
for all of them.
When attempting to take the address of the function declared in A, the compiler generates the following error:
....................................................
test.cpp:28: `A' is an ambiguous base of `D'
test.cpp:28: confused by earlier errors, bailing out
....................................................
GCC 2.95.3 and GCC 2.96 compile this code without any errors/warnings.
>How-To-Repeat:
/************************************************/
/* Compile the following with `gcc -c test.cpp' */
/************************************************/
class A{
public:
virtual void a() = 0;
};
class B : public A
{
public:
virtual void b() = 0;
};
class C : public A
{
public:
virtual void c() = 0;
};
class D : public B, public C
{
public:
virtual void a() {}
virtual void b() {}
virtual void c() {}
typedef void ( D::*FNTYPE)(void);
static FNTYPE const s_fxn[];
};
D::FNTYPE const D::s_fxn[] = { (FNTYPE)&D::a };
/************************************************/
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: