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. Release: 3.2 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++ 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 }; /************************************************/
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 right. 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; ------------------------------- Messages: 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
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 Cc: Subject: Re: c++/8117: [3.2 regression] member function pointers and multiple inheritance 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. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8117
State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed for 3.3 and trunk; 3.2 branch is now closed.