🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

"virtual XXX operator XXX" functions

#304
From: Michael Tiemann
Date: Fri, 28 Jul 1989 20:51
52 lines
2776 bytes
    There seems to be a bug in G++ version 1.35.  I am running g++-1.35 on 
    a vax 785 under the mach operating system (but this program was loaded
    without just the standard BSD4.3 libraries).  I also ran it on a VAX 8650 
    running 4.3+NFS with the same result.

    The basic problem seems to be within "virtual XXX operator XXX" functions.  
    The child has no means of accessing the parent's "operator XXX" function,
    and when it tries, the child simply calls itself.  I have tried several 
    means of specifying the parent function from within the child's function
    "operator XXX", including: Parent::operator XXX(), (XXX&)*(Parent*)this,
    and (XXX&)(Parent&)*this.  All forms cause the child to call itself, not
    the parent's function.  (some of them should call the child's routine,
    but parent::operator XXX() should call the parent's routine).

The first element of the following diff is a bonus.  The second
element is the fix you need.

yahi% diff -c2 cplus-method.c~ cplus-method.c
*** cplus-method.c~	Fri May 26 00:06:51 1989
--- cplus-method.c	Fri Jul 28 13:48:13 1989
***************
*** 2172,2177 ****
  		&& TREE_CODE (type) != METHOD_TYPE
  		&& (TREE_CODE (type) != POINTER_TYPE
! 		    || TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE
! 		    || TREE_CODE (TREE_TYPE (type)) != METHOD_TYPE))
  	    {
  	      error ("component `%s' is not a method",
--- 2172,2177 ----
  		&& TREE_CODE (type) != METHOD_TYPE
  		&& (TREE_CODE (type) != POINTER_TYPE
! 		    || (TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE
! 			&& TREE_CODE (TREE_TYPE (type)) != METHOD_TYPE)))
  	    {
  	      error ("component `%s' is not a method",
***************
*** 2332,2336 ****
  	      this_this = convert_to_nonzero_pointer (build_pointer_type (TREE_TYPE (of)), current_class_decl);
  	      return build_method_call (this_this, name, NULL_TREE,
! 					NULL_TREE, flags);
  	    }
  	  else if (current_class_decl)
--- 2332,2336 ----
  	      this_this = convert_to_nonzero_pointer (build_pointer_type (TREE_TYPE (of)), current_class_decl);
  	      return build_method_call (this_this, name, NULL_TREE,
! 					NULL_TREE, flags | LOOKUP_NONVIRTUAL);
  	    }
  	  else if (current_class_decl)
yahi% 

Michael
Technical Details
Message-ID: <8907282051.AA29606@yahi.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!YAHI.STANFORD.EDU!tiemann
References: <8905251621.AA10782@notecnirp.Princeton.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!YAHI.STANFORD.EDU!tiemann
From: tiemann@YAHI.STANFORD.EDU (Michael Tiemann)
Newsgroups: gnu.g++.bug
Subject: "virtual XXX operator XXX" functions
Message-ID: <8907282051.AA29606@yahi.Stanford.EDU>
Date: 28 Jul 89 20:51:31 GMT
References: <8905251621.AA10782@notecnirp.Princeton.EDU>
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: tiemann@lurch.stanford.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 52