🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Problems with virtual functions and multiple inheritance

#789
From: etnkna
Date: Thu, 13 Aug 1992 16:22
90 lines
2527 bytes
I am using gcc-2.2.2 with the gdb-4.6 fix on a sparc using sunos4.1.

The file bugtest.cc:

------------------------------------------------------------------------------
#include <stream.h>

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

struct b
{
    virtual void g() = 0;
};

struct c: public a, public b
{
    virtual void f();
    virtual void g();
};

void c::f()
{
    cerr << "c::f()\n";
}

void c::g()
{
    cerr << "c::g()\n";
}

struct e: public b
{
    // virtual void g();
};

// void e::g()
// {
//    cerr << "e::g()\n";
// }

struct h
{
};

struct d: public c, public e, public h
{
    virtual void f();
    virtual void g();
};


void d::f()
{
    cerr << "d::f()\n";
}

void d::g()
{
    cerr << "d::g()\n";
}

int main(int argc, char* argv[])
{
    a* tmp = new d;
    tmp->f();
    return 0;
}
    
-------------------------------------------------------------------------------
produces the following messages when compiling:

g++ -v -o bugtest bugtest.cc
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/specs
gcc version 2.2.2
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix bugtest.cc /usr/tmp/cca24609.i
GNU CPP version 2.2.2 (sparc)
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/cc1plus /usr/tmp/cca24609.i -quiet -dumpbase bugtest.cc -version -o /usr/tmp/cca24609.s
GNU C++ version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
bugtest.cc: In function `int  main (int, char **)':
bugtest.cc:63: cannot allocate an object of type `d'
bugtest.cc:63: since the following virtual functions are abstract:
bugtest.cc:10: void  b::g ()

-------------------------------------------------------------------------------
Name:	Knut-Hevard Aksnes (ECMA 94) or		Knut-Haavard Aksnes (ASCII)
Ericsson signature: HI/ETN/U/IT KNA		Phone: +47 41 19481
Email: etnkna@etn.ericsson.se (internet)  ETN.ETNKNA (memo)
Technical Details
Message-ID: <9208131422.AA24627@hisoy2>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!ames!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!etn.ericsson.SE!etnkna

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!ames!elroy.jpl.nasa.gov!swrinde!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!etn.ericsson.SE!etnkna
From: etnkna@etn.ericsson.SE
Newsgroups: gnu.g++.bug
Subject: Problems with virtual functions and multiple inheritance
Message-ID: <9208131422.AA24627@hisoy2>
Date: 13 Aug 92 16:22:41 GMT
Sender: gnulists@ai.mit.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 90
Approved: bug-g++@prep.ai.mit.edu