Path: 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 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 () { }