Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Ron Guilmette
Thu, 04 May 1989 19:40
BUG in G++ 1.35.0- (c025)
Author: Ron Guilmette
Date: Thu, 04 May 1989 19:40
Date: Thu, 04 May 1989 19:40
48 lines
1485 bytes
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 ()
{
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads