[gnu.g++.bug] Patch Re: Bad constructor code in G++ 1.27.0

cooper@UUNET.UU.NET (Clark Cooper) (10/25/88)

	In message <8810241502.AA02620@gecrux.steinmetz>, I described a
bug in G++ 1.27.0 that caused incorrect code to be generated for some
derived constructors. I believe the patch below fixes the problem without
introducing new ones.

	I tested out the G++ compiler with this patch on InterViews 2.4,
where I originally discovered the bug. It compiled successfully as did
the InterViews Window Manager. The InterViews Window Manager appears to
work correctly with this patch to the compiler.

	Since I'm not initimate with this code, this patch should probably
be treated with suspicion until Michael Tiemann, or someone else closely
associated with it, can pass on it.

================
*** ../dist-g++/init.c.orig	Tue Sep 20 09:43:23 1988
--- init.c	Tue Oct 25 08:45:05 1988
***************
*** 265,285 ****
    for (i = 1; i <= n_baseclasses; i++)
      {
        tree base = current_class_decl;
  
        basetype = CLASSTYPE_BASECLASS (current_class_type, i);
!       if (TREE_VIRTUAL (basetype))
! 	base = convert_to_nonzero_pointer (TYPE_POINTER_TO (basetype),
! 					   current_class_decl);
! 
!       if (! CLASSTYPE_VIA_VIRTUAL (current_class_type, i)
! 	  && (TREE_VIRTUAL (basetype) | TREE_NEEDS_CONSTRUCTOR (basetype)))
  	{
! 	  if (! CLASSTYPE_MARKED3 (basetype))
  	    do_aggr_init (build_indirect_ref (base, 0), NULL_TREE,
  			  CLASSTYPE_OFFSET (basetype) == integer_zero_node);
  	}
        CLASSTYPE_MARKED3 (basetype) = 0;
  
        /* Now, if this base class did not come "straight-up",
  	 straighten it here.  "Straighten" has quite a funny
  	 spelling, but we do not report that here.  */
--- 265,285 ----
    for (i = 1; i <= n_baseclasses; i++)
      {
        tree base = current_class_decl;
  
        basetype = CLASSTYPE_BASECLASS (current_class_type, i);
!       if (TREE_NEEDS_CONSTRUCTOR (basetype) || TREE_VIRTUAL (basetype))
  	{
! 	  base = convert_to_nonzero_pointer (TYPE_POINTER_TO (basetype),
! 					     current_class_decl);
! 
! 	  if (! (CLASSTYPE_VIA_VIRTUAL (current_class_type, i)
! 		 || CLASSTYPE_MARKED3 (basetype)))
  	    do_aggr_init (build_indirect_ref (base, 0), NULL_TREE,
  			  CLASSTYPE_OFFSET (basetype) == integer_zero_node);
  	}
+ 
        CLASSTYPE_MARKED3 (basetype) = 0;
  
        /* Now, if this base class did not come "straight-up",
  	 straighten it here.  "Straighten" has quite a funny
  	 spelling, but we do not report that here.  */
----
Clark Cooper       cooper@gecrux.steinmetz.ge.com, coopercc@crd.ge.com,
                   coopercc@ge-crd.arpa, ...!uunet!steinmetz!cooper