Bug 8117 - [3.2 regression] member function pointers and multiple inheritance
Summary: [3.2 regression] member function pointers and multiple inheritance
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P1 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: rejects-valid
Depends on:
Reported: 2002-10-02 00:56 UTC by yuvalk
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description yuvalk 2002-10-02 00:56:00 UTC
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.


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++

/* Compile the following with `gcc -c test.cpp' */
class A{
		virtual void a() = 0;

class B : public A
		virtual void b() = 0;

class C : public A
		virtual void c() = 0;

class D : public B, public C
	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 };
Comment 1 Wolfgang Bangerth 2002-11-04 14:58:17 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Right, this is a regression since it did compile with 2.95.
    Thus, priority "high". However, present CVS compiles it
    Code in question:
    struct A {
        virtual void a() = 0;
    struct B : A {};
    struct C : A {};
    struct D : B, C {
        virtual void a() {}
    void (D::*s_fxn)() = &D::a;
    tmp/g> /home/bangerth/bin/gcc-3.2.1-pre/bin/c++ -c x.cc
    x.cc:12: `A' is an ambiguous base of `D'
    x.cc:12: confused by earlier errors, bailing out
Comment 2 janis187 2002-12-13 16:56:54 UTC
From: Janis Johnson <janis187@us.ibm.com>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, yuvalk@mainsoft.com,
   gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org
Subject: Re: c++/8117: [3.2 regression] member function pointers and multiple 
Date: Fri, 13 Dec 2002 16:56:54 -0800

 This regression from 3.0.4 has been fixed on the mainline
 but still exists in the 3.2 branch.
 The bug showed up when this patch was added:
 2001-11-28  Nathan Sidwell  <nathan@codesourcery.com>
         * cp-tree.h (UNIQUELY_DERIVED_FROM_P): Use lookup base.
         * call.c (standard_conversion): Use lookup_base.
         * class.c (strictly_overrides): Likewise.
         * cvt.c (build_up_reference): Adjust comment.
         * init.c (build_member_call): Reformat.
         * search.c (get_binfo): Remove.
         * tree.c (binfo_value): Remove.
         * typeck.c (build_static_cast): Use lookup_base.
         * typeck2.c (binfo_or_else): Use lookup_base.
 The bug went away on the mainline when this patch was added:
 2002-10-25  Mark Mitchell  <mark@codesourcery.com>
         * call.c (build_over_call): Use DECL_CONTEXT, not
         * class.c (modify_vtable_entry): Don't mess with
         * cp-tree.h (lang_type_class): Remove vsize.
         * pt.c (build_template_decl): Don't set it.
         * typeck.c (expand_ptrmemfunc_cst): Don't use it.
Comment 3 Joe Buck 2003-04-25 19:43:43 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed for 3.3 and trunk; 3.2 branch is now closed.