🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1371

2.3.3 multiple inheritance: wrong virtuals called

#1371
From: enewton
Date: Mon, 28 Dec 1992 19:12
63 lines
1389 bytes
// gcc version 2.3.3 configured with ./configure sun4 on a Sun IPX.
// compiled with gcc -xc++ bug.c
// running ./a.out yields incorrect output
// I see:
//  D's create
//  D's create
//  D's create
//
// current workaround is to never compile the constructor from
// classes multiply-derived from the same parent in the same source
// file.  On tuesdays. 8-)
//
// -Eric uunet.uu.net!srg!enewton
//

extern "C" {
   void puts(const char *);
}

/*
	A   Q
	 \ /
	  C
	 / \
	D   E

*/

class A
{
 public:
   virtual void f() {}
};

class Q
{
 public:
   virtual void create() { puts("Q's create"); }
};

class C : public A,public Q
{
};

class E : public C
{
 public:
   virtual void create() { puts("E's create"); }
};

class D : public C
{
 public:
   virtual void create() { puts("D's create"); }
};

main()
{
   C * p;
   p = new C; p->create();
   p = new D; p->create();
   p = new E; p->create();
}
Technical Details
Message-ID: <9301081115.bc09627@srg.srg.af.mil>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!uunet.uu.net!enewton

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!uunet.uu.net!enewton
From: enewton@uunet.uu.net
Subject: 2.3.3 multiple inheritance: wrong virtuals called
Message-ID: <9301081115.bc09627@srg.srg.af.mil>
Sender: gnulists@ai.mit.edu
Reply-To: srg!enewton@uunet.uu.net
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 28 Dec 1992 19:12:02 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 66