🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: g++ 2.2.2 crashes when using multiple inheritance

#870
From: Marvin Solomon
Date: Tue, 01 Sep 1992 11:07
57 lines
2098 bytes
In article <9208291541.AA00156@cygnus.com> mrs@cygnus.com (Mike Stump) writes:
>cygnus bash[910] gcc -S -B./ t3.cc
>t3.cc: In function `void  g (struct A*)':
>t3.cc:15: cannot convert a pointer of type `A'
>t3.cc:15: to a pointer of type `B'
>cygnus bash[911] 
>
>is what I get now.  no dump, but I suspect it is wrong.

Yes, it is wrong. The variable ptr has type A* so ptr->f() should call A::f. 
There's absolutely no ready why the compiler should be trying to convert ptr
to a B*.  Note that if you remove the declaration of C (which is not
referenced anywhere), the problem goes away.

>
>> From: adams@cs.wisc.edu (Paul Adams)
>> Message-Id: <9208272057.AA03920@grana.cs.wisc.edu>
>> To: bug-g++@prep.ai.mit.edu
>> Date: Thu, 27 Aug 92 15:57:10 CDT
>
>> Hi.  The following program causes g++ 2.2.2 to crash.  
>
>> Hierarchy:
>
>>         A       B
>>          \     /
>>           v   v
>>            \ /
>>             C
>
>> The crash occurs if either B or C (or both) are virtual base classes of C.
>> The program compiles fine if non-virtual base classes are used. 
>
>> --------------------------------------------------------------------------------
>> Script started on Thu Aug 27 15:28:22 1992
>> adams 21>cat bug2.c
>> struct A {
>> 	virtual void f();
>> }; 
>
>> struct B {
>> 	virtual void f() ;
>> }; 
>
>> struct C : virtual A , virtual B {
>> 	virtual void f();
>> };
>
>> void g(A *ptr)
>> {
>> 	ptr->f();
>> }
-- 
	Prof. Marvin Solomon
	Computer Sciences Department
	University of Wisconsin, Madison WI
	solomon@cs.wisc.edu
Technical Details
Message-ID: <1992Sep1.110732.12569@cs.wisc.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.wisc.edu!solomon
References: <9208291541.AA00156@cygnus.com>

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.wisc.edu!solomon
From: solomon@cs.wisc.edu (Marvin Solomon)
Subject: Re:  g++ 2.2.2 crashes when using multiple inheritance
Message-ID: <1992Sep1.110732.12569@cs.wisc.edu>
Sender: gnulists@ai.mit.edu
Organization: University of Wisconsin, Madison -- Computer Sciences Dept.
References: <9208291541.AA00156@cygnus.com>
Distribution: gnu
Date: Tue, 1 Sep 1992 11:07:32 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 58