Article View: gnu.g++.bug
Article #1200virtual function resolution bug in gcc-2.3.3
From: Michael N. Lipp
Date: Sat, 02 Jan 1993 16:15
Date: Sat, 02 Jan 1993 16:15
79 lines
1796 bytes
1796 bytes
Compiling this program (using gcc-2.3.3 and Sparc/SunOS or
PC/Linux) results in the faulty output "M::F1". If you remove F1 and
F2 from class M (or declare GetC as first method) you get the correct
output T::GetC.
--------------------------------------------------
// -*- c++ -*-
#include <iostream.h>
class C
{
public:
int i;
};
class M
{
private:
C* c;
public:
virtual void F1 ();
virtual void F2 ();
virtual C* GetC () = 0;
};
void M::F1 ()
{
cout << "M::F1\n";
}
void M::F2 ()
{
cout << "M::F2\n";
}
class F
{
private:
C* c;
public:
virtual C* GetC () = 0;
};
class T : public M, public F
{
private:
C* c;
public:
virtual C* GetC ();
};
C* T::GetC ()
{
cout << "T::GetC\n";
return c;
}
main ()
{
T o;
T* op = &o;
op->GetC ();
}
--------------------------------------------------
Michael
--
-----------------,------------------------------,------------------------------
Michael N. Lipp ! Institut fuer Datentechnik ! Phone: 49-6151-163776
! Merckstr. 25 ,----------' Fax: 49-6151-164976
! D-6100 Darmstadt ! E-Mail:
! (Germany) ! mnl@dtro.e-technik.th-darmstadt.de
-----------------'-------------------'-----------------------------------------
Technical Details
Message-ID:
<MNL.93Jan2161553@mnlsun.dtro.e-technik.th-darmstadt.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!dtro.e-technik.TH-darmstadt.DE!mnlShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!dtro.e-technik.TH-darmstadt.DE!mnl From: mnl@dtro.e-technik.TH-darmstadt.DE (Michael N. Lipp) Subject: virtual function resolution bug in gcc-2.3.3 Message-ID: <MNL.93Jan2161553@mnlsun.dtro.e-technik.th-darmstadt.de> Sender: gnulists@ai.mit.edu Organization: TH-Darmstadt Distribution: gnu Date: Sat, 2 Jan 1993 16:15:53 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 80