This is the mail archive of the 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 383

this fixes bug 383 where we failed to find a templated conversion operator
to reference type.

[] appears to be incomplete. It forgets that we might be looking
for a conversion operator to reference type, and be deducing against an
operator that returns a reference type. In that case, we do not want to
use the type referenced by A for deduction.  This is much the same problem
as DR 214 points out about template function ordering and reference
parameters.  I'll submit a defect report presently.

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

Dr Nathan Sidwell   ::   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?' : :
2001-12-26  Nathan Sidwell  <>

	PR c++/383
	* pt.c (maybe_adjust_types_for_deduction): DEDUCE_CONV might meet
	two reference types.
Index: cp/pt.c
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.566
diff -c -3 -p -r1.566 pt.c
*** pt.c	2001/12/18 14:13:44	1.566
--- pt.c	2001/12/26 18:50:10
*************** maybe_adjust_types_for_deduction (strict
*** 7785,7790 ****
--- 7785,7798 ----
  	tree* temp = parm;
  	parm = arg;
  	arg = temp;
+ 	/* Defect: [temp.deduct.conv] does not work when looking for a
+ 	   conversion to reference type, and testing against a
+ 	   conversion function which returns a reference type.  This
+ 	   is much the same problem as DR 214 (see below).  */
+ 	    && TREE_CODE (*parm) == REFERENCE_TYPE)
+ 	  return 0;
// { dg-do compile }

// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 26 Dec 2001 <>

// PR 383. Deducing template conversions to reference type. Apparent
// defect in standard.

enum TestEnumFlag { FlagNo, FlagYes};

struct SubjTop {};

template <TestEnumFlag TEST_FLAG>
struct Subj1 : public SubjTop
  template <TestEnumFlag AS_TF>
  operator Subj1<AS_TF>& ()
    return static_cast<Subj1<AS_TF>&>(t);

  typedef Subj1<FlagYes> Subj1Yes;
  typedef Subj1<FlagNo> Subj1No;
  Subj1Yes x;
  Subj1No&y=x;  // got bogus error
  return 0;

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