Article View: gnu.g++.bug
Article #807Re: Problems with virtual functions and multiple inheritance
From: Ross Huitt
Date: Fri, 14 Aug 1992 19:58
Date: Fri, 14 Aug 1992 19:58
41 lines
1254 bytes
1254 bytes
Strange. The compiler message is valid. However, I looked at the problem and
tried to reduce it to its smallest form. Suprisingly, the error message
disappeared! But, as you would it suspect, it coredumps right on cue.
So where did the error message go to?
#include <iostream.h>
struct b {
virtual void g() = 0;
};
struct c : public b {
virtual void g() { cout << "c::g()" << endl; }
};
struct e : public b {
};
struct d : public c, public e {
virtual void g() { cout << "d::g()" << endl; }
};
main()
{
d *D = new d;
b *bc = (b *)((c *)D);
b *be = (b *)((e *)D);
D->g();
bc->g();
be->g();
return 0;
}
The above code, when run, produced:
c::g()
d::g()
Abort (core dumped)
Ross Huitt
bytor@ctt.bellcore.com
Technical Details
Message-ID:
<1992Aug14.195855.21782@walter.bellcore.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!grumpy.bellcore.com!bytorReferences:
<9208131422.AA24627@hisoy2>Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!grumpy.bellcore.com!bytor From: bytor@grumpy.bellcore.com (Ross Huitt) Subject: Re: Problems with virtual functions and multiple inheritance Message-ID: <1992Aug14.195855.21782@walter.bellcore.com> Sender: gnulists@ai.mit.edu Organization: Bellcore References: <9208131422.AA24627@hisoy2> Distribution: gnu Date: Fri, 14 Aug 1992 19:58:55 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 42