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- (pre-release) Message-ID: <8905022253.AA17731@riunite.aca.mcc.com> Date: 2 May 89 22:53:59 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 75 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