🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

BUG in G++ 1.35.0- (c025)

#1946
From: Ron Guilmette
Date: Thu, 04 May 1989 19:40
48 lines
1485 bytes
The following program incorrectly returns a non-zero exit status because
a new call to "base_returning_function" is generated for each usage of
the reference constant "base_ref".

-------------------------------------------------------------------------
// Check that if a reference is initialized to refer to a value
// which is returned from a function call, the actual call to
// the function is only invoked for the original initialization
// of the reference, and not for each subsequent use of the
// reference.
//
// This test fails with G++ 1.35.0- (pre-release).
// Reported 4/4/89 by Kim Smith

struct base {
	int data_member;

	void function_member ();
};

base base_object;

base base_returning_function ();

int call_count = 0;

int main ()
{
	base& base_ref = base_returning_function ();

	base_ref.function_member ();
	base_ref.function_member ();
	base_ref.data_member  = 99;
	return (call_count == 1) ? 0 : 1;
}

base base_returning_function ()
{
	base local_base_object;

	call_count++;
	return local_base_object;
}

void base::function_member ()
{
}
Technical Details
Message-ID: <8905041940.AA29316@riunite.aca.mcc.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MCC.COM!rfg

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MCC.COM!rfg
From: rfg@MCC.COM (Ron Guilmette)
Newsgroups: gnu.g++.bug
Subject: BUG in G++ 1.35.0- (c025)
Message-ID: <8905041940.AA29316@riunite.aca.mcc.com>
Date: 4 May 89 19:40:14 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 48