This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for PR c++/8748


Another case of inappropriate use of save_expr caught by the cp_expr_size
change; we can't save an expression of class type, as that would involve a
bitwise copy.  Test in g++.dg/init/save1.C.

Tested i686-pc-linux-gnu, applied to trunk and 3.3.

2003-01-13  Jason Merrill  <jason@redhat.com>

	PR c++/8748
	* class.c (build_base_path): Take the address before calling save_expr.

*** class.c.~1~	Sun Jan 12 22:55:58 2003
--- class.c	Sun Jan 12 22:51:24 2003
*************** build_base_path (code, expr, binfo, nonn
*** 291,303 ****
        return error_mark_node;
      }
  
    fixed_type_p = resolves_to_fixed_type_p (expr, &nonnull);
    if (fixed_type_p <= 0 && TREE_SIDE_EFFECTS (expr))
      expr = save_expr (expr);
  
!   if (!want_pointer)
!     expr = build_unary_op (ADDR_EXPR, expr, 0);
!   else if (!nonnull)
      null_test = build (EQ_EXPR, boolean_type_node, expr, integer_zero_node);
    
    offset = BINFO_OFFSET (binfo);
--- 291,305 ----
        return error_mark_node;
      }
  
+   if (!want_pointer)
+     /* This must happen before the call to save_expr.  */
+     expr = build_unary_op (ADDR_EXPR, expr, 0);
+ 
    fixed_type_p = resolves_to_fixed_type_p (expr, &nonnull);
    if (fixed_type_p <= 0 && TREE_SIDE_EFFECTS (expr))
      expr = save_expr (expr);
  
!   if (want_pointer && !nonnull)
      null_test = build (EQ_EXPR, boolean_type_node, expr, integer_zero_node);
    
    offset = BINFO_OFFSET (binfo);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]