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]

Re: PATCH for crash with incomplete types


>>>>> "Jason" == Jason Merrill <jason@cygnus.com> writes:

    >> convert_arguments was almost line-for-line identical, but the
    >> "old code" did a check to make sure that the arguments weren't
    >> of incomplete type, which the "new code" did not.  Would you
    >> prefer that I copy this check into the new code, thereby
    >> increasing the duplication?

    Jason> No; actually, it should be caught in resolve_args.

No, actually, that's no good either.  Consider:

  void f(int*);
  extern int a[];
  void g() { 
    f(a);
  }

We can't check that `a' have complete type because we haven't
converted it yet.  

    Jason> before deciding which function to call.  It doesn't need to
    Jason> handle all the other stuff that convert_arguments does, and
    Jason> I'd rather not get it mixed up in there.

Thanks for explaining this.  I've attached a revised patch that does
not fixes the problem more cleanly, I think.  Is it OK?

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com

1998-06-10  Mark Mitchell  <mark@markmitchell.com>

	* call.c (convert_like): Don't fail silently if 
	build_user_type_conversion fails.  Always return error_mark_node 
	for failure.

Index: call.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/call.c,v
retrieving revision 1.88
diff -c -p -r1.88 call.c
*** call.c	1998/06/10 10:50:44	1.88
--- call.c	1998/06/10 23:05:55
*************** convert_like (convs, expr)
*** 3155,3162 ****
  	return expr;
        /* else fall through */
      case BASE_CONV:
!       return build_user_type_conversion
! 	(TREE_TYPE (convs), expr, LOOKUP_NORMAL);
      case REF_BIND:
        return convert_to_reference
  	(TREE_TYPE (convs), expr,
--- 3154,3185 ----
  	return expr;
        /* else fall through */
      case BASE_CONV:
!       {
! 	tree cvt_expr = build_user_type_conversion
! 	  (TREE_TYPE (convs), expr, LOOKUP_NORMAL);
! 	if (!cvt_expr) 
! 	  {
! 	    /* This can occur if, for example, the EXPR has incomplete
! 	       type.  We can't check for that before attempting the
! 	       conversion because the type might be an incomplete
! 	       array type, which is OK if some constructor for the
! 	       destination type takes a pointer argument.  */
! 	    if (TYPE_SIZE (TREE_TYPE (expr)) == 0)
! 	      {
! 		if (comptypes (TREE_TYPE (expr), TREE_TYPE (convs), 1))
! 		  incomplete_type_error (expr, TREE_TYPE (expr));
! 		else
! 		  cp_error ("could not convert `%E' (with incomplete type `%T') to `%T'",
! 			    expr, TREE_TYPE (expr), TREE_TYPE (convs));
! 	      }
! 	    else
! 	      cp_error ("could not convert `%E' to `%T'",
! 			expr, TREE_TYPE (convs));
! 	    return error_mark_node;
! 	  }
! 	return cvt_expr;
!       }
! 
      case REF_BIND:
        return convert_to_reference
  	(TREE_TYPE (convs), expr,


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