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]:Fix 14397


Mark,
this fixes 14397 a fallout from your 12226 patch. I'm mildly concerned
that we're building an IDENTITY_CONV for something that's really a
QUAL_CONV. I think this is another case of us not doing the algorithm
in the std, but doing one nearly the same that (presumably) has the same
outputs.

built and tested on i686-pc-linux-gnu, ok?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-03-05  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/14397
	* call.c (convert_like_real): Build a const qualified temporary,
	when testing ctor access.

Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.452.2.9
diff -c -3 -p -r1.452.2.9 call.c
*** cp/call.c	2 Mar 2004 19:57:04 -0000	1.452.2.9
--- cp/call.c	5 Mar 2004 16:18:31 -0000
*************** convert_like_real (tree convs, tree expr
*** 3991,4008 ****
      case IDENTITY_CONV:
        if (type_unknown_p (expr))
  	expr = instantiate_type (totype, expr, tf_error | tf_warning);
!       /* Convert a non-array constant variable to its underlying value, unless we
! 	 are about to bind it to a reference, in which case we need to
! 	 leave it as an lvalue.  */
        if (inner >= 0
  	  && TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
  	expr = decl_constant_value (expr);
        if (CHECK_COPY_CONSTRUCTOR_P (convs))
  	/* Generate a temporary copy purely to generate the required
  	   diagnostics.  */
! 	build_temp (build_dummy_object (totype), totype, 
! 		    LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING,
! 		    &diagnostic_fn);
  	return expr;
      case AMBIG_CONV:
        /* Call build_user_type_conversion again for the error.  */
--- 3991,4009 ----
      case IDENTITY_CONV:
        if (type_unknown_p (expr))
  	expr = instantiate_type (totype, expr, tf_error | tf_warning);
!       /* Convert a non-array constant variable to its underlying
! 	 value, unless we are about to bind it to a reference, in
! 	 which case we need to leave it as an lvalue.  */
        if (inner >= 0
  	  && TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
  	expr = decl_constant_value (expr);
        if (CHECK_COPY_CONSTRUCTOR_P (convs))
  	/* Generate a temporary copy purely to generate the required
  	   diagnostics.  */
! 	build_temp
! 	  (build_dummy_object
! 	   (build_qualified_type (totype, TYPE_QUAL_CONST)),
! 	   totype, LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING, &diagnostic_fn);
  	return expr;
      case AMBIG_CONV:
        /* Call build_user_type_conversion again for the error.  */
// Copyright (C) 2004 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 5 Mar 2004 <nathan@codesourcery.com>

// Origin: schmid@snake.iap.physik.tu-darmstadt.de
// Bug 14397: Bogus access error.

struct S { 
    S (int); 
    S(S const&); 
  private: 
    S(S&); 
}; 
 
S foo() 
{ 
  int result = 0;
  
  S s ((0,S (result)));
  
  return S (result); 
} 

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