🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

g++ bug

#363
From: Dominick Samperi
Date: Mon, 21 Aug 1989 02:05
47 lines
1274 bytes
The C++ program below illustrate a g++ bug. The function getx() is called
twice, once when x.f() is invoked. When compiled under Zortek C++ getx() is
called only once, as I would expect.

Please let me know if this is a known problem, to be fixed, etc. Thanks!

Dominick Samperi
Citicorp, NAIB
uunet!naib!samperi

/*
*	g++bug.c -- Illustrates a g++ bug. The function getx() below is called
*		    twice, once incorrectly when x.f() is executed.
*
*		    Dominick Samperi, Citicorp, NAIB
*		    uunet!naib!samperi
*/

#include <stream.h>

class xclass {
      public:
	void f() {cout << "(xclass.f)\n";}
};

xclass&
getx() {
	xclass& q = *(new xclass);
	cout << "(getx)\n";
	return q;
}

main () {
	xclass& x = getx();
	x.f();
/*
*  Output is:
*
*  (getx)
*  (getx)
*  (xclass.f)
*
*  Looks like getx() is being called again when x.f() is executed.
*/

}
Technical Details
Message-ID: <8908210205.AA12004@naib.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!UUNET.UU.NET!naib!dsamperi

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!UUNET.UU.NET!naib!dsamperi
From: naib!dsamperi@UUNET.UU.NET (Dominick Samperi)
Newsgroups: gnu.g++.bug
Subject: g++ bug
Message-ID: <8908210205.AA12004@naib.com>
Date: 21 Aug 89 02:05:46 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 47