🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Ron Guilmette Tue, 02 May 1989 22:53
BUG in G++ 1.35.0- (pre-release)
#1932
Author: Ron Guilmette
Date: Tue, 02 May 1989 22:53
75 lines
2516 bytes
As the following short program demonstrates, G++ 1.35.0- breaks
the semantics of the method-call operator ->()() in that it causes
the method call operator to be invoked *even* when it didn't use to
be, i.e. when you are calling a member function of the current
class from within another member function of the current class.

The following patch seems to fix the problem, but I am not at all sure
that this is the "correct" solution.  It just seems to work.

diff -rc2 1.35-.0--/cplus-class.c 1.35-.0-+/cplus-class.c
*** 1.35-.0--/cplus-class.c	Wed Apr 19 00:45:12 1989
--- 1.35-.0-+/cplus-class.c	Tue May  2 17:31:14 1989
***************
*** 3454,3458 ****
  	       || strncmp (IDENTIFIER_POINTER (DECL_NAME (function)),
  			   "op$method_call", 13))
! 	   && (may_be_remote (basetype) || instance != C_C_D))
      {
        register int used, size;
--- 3454,3458 ----
  	       || strncmp (IDENTIFIER_POINTER (DECL_NAME (function)),
  			   "op$method_call", 13))
! 	   && (may_be_remote (basetype) || (C_C_D ? (TREE_TYPE (instance) != TREE_TYPE(C_C_D)) : 1 )))
      {
        register int used, size;

---------------------------------------------------------------------------------
typedef int MP;

class base;

typedef void (base::*base_method_ptr) ();

class base {
	int member;
public:
	base () {}
	base operator ->() (MP method_id, int arg_bytes, ...)
	{
		base_method_ptr bmp = (base_method_ptr) method_id;

		printf ("operator->()() called\n");
		(this->*(bmp)) ();
	}
};

class derived : public base {
	int member;
public:
	derived () {}
	void method_1 ()
	{
		printf ("method_1() called\n");
	}
	void method_2 ()
	{
		printf ("method_2() called\n");
		method_1 ();
	}
};

int main ()
{
	derived derived_object;

	derived_object.method_2 ();
}
---------------------------------------------------------------------------------


// Ron Guilmette  -  MCC  -  Experimental Systems Kit Project
// 3500 West Balcones Center Drive,  Austin, TX  78759  -  (512)338-3740
// ARPA: rfg@mcc.com
// UUCP: {rutgers,uunet,gatech,ames,pyramid}!cs.utexas.edu!pp!rfg
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