This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Defect in private virtual inheritance
- To: "'egcs-bugs at cygnus dot com'" <egcs-bugs at cygnus dot com>
- Subject: Defect in private virtual inheritance
- From: Brian Bray <brianbr at ibm dot net>
- Date: Thu, 8 Jan 1998 13:26:04 -0800
I installed egcs 1.0 with the RH5 patch on a pentium 90 running Linux Redhat 5.0.
First of all, thank you for releasing this compiler. I was able to remove a lot of the workarounds in my code for gcc 2.7.2.3. I have some problems with gdb, but these have already been reported. Finally I can turn on optimizations and exception handling at the same time. The static space overhead is very high in this release, but at least it works.
My problem is in using a private virtual base class to communicate between mix-in classes in a framework. I'm getting spurious access violations on the destructor for the private virtual base. The problem is reproducable with this code:
#include <iostream.h>
class Priv
{
public:
#ifdef SHOWBUG
~Priv() {}
#endif
virtual bool hasMixin() {return false;}
};
class Pub : virtual private Priv
{
public:
void doIt()
{cout << "Has mixin: " << hasMixin() << endl;}
};
class Mixin : virtual private Priv
{
public:
bool hasMixin() {return true;}
};
class Client1 : public Pub
{};
class Client2 : public Pub, public Mixin
{};
int main(int, char **)
{
Client1 c1;
Client2 c2;
c1.doIt();
c2.doIt();
return 0;
}
If I declare the destructor, I get the spurious errors:
client.cpp: In method `Client1::~Client1()':
client.cpp:8: `Priv::~Priv()' is from private base class
client.cpp:35: within this context
client.cpp: In method `Client2::~Client2()':
client.cpp:8: `Priv::~Priv()' is from private base class
client.cpp:36: within this context
I don't get an access error from using the compiler supplied default destructor or with a constructor of any kind.
-Brian Bray
brianbr@ibm.net