🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.help
Article #430

Dispatching bug in g++?

#430
From: Konstantin Laufer
Date: Fri, 16 Oct 1992 20:48
39 lines
1427 bytes
Excuse me if this is already a well-known bug, but I don't read this
group regularly.  Consider the following program:

#include <stream.h>

class P {
public:
  virtual void hello() { cout << "hello\n"; }
  void callhello() { hello(); }
};

class C : public P {
public:
  virtual void hello() { cout << "hullo\n"; }
};

void g(P x) { x.callhello(); }	// should call P::hello()

int main() {
  C z;
  z.hello();			// calls C::hello()
  g(z);				// results in an erroneous call to C::hello()!
}

When compiled with g++ 2.2.2 under SunOS 4.1.2, this program produces
the erroneous output
	hullo
	hullo

This is incorrect, since the x is a value parameter, whence
dispatching should be static.

Compilation with AT&T CC correctly results in
	hullo
	hello

Have other people observed this problem?
-- 
-Konstantin [laufer@math.luc.edu]
Technical Details
Message-ID: <1992Oct16.204850.3311@lucpum.it.luc.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!uwm.edu!daffy!uwvax!uchinews!lucpum.it.luc.edu!math.luc.edu!laufer

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.help
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!uwm.edu!daffy!uwvax!uchinews!lucpum.it.luc.edu!math.luc.edu!laufer
From: laufer@math.luc.edu (Konstantin Laufer)
Subject: Dispatching bug in g++?
Message-ID: <1992Oct16.204850.3311@lucpum.it.luc.edu>
Sender: root@lucpum.it.luc.edu (System PRIVILEGED Account)
Reply-To: laufer@math.luc.edu
Fcc: +work/teaching
Organization: Loyola University Chicago
Date: Fri, 16 Oct 1992 20:48:50 GMT
Lines: 39