This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]: Fix 383
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: mark at codesourcery dot com
- Date: Thu, 27 Dec 2001 20:08:45 GMT
- Subject: [C++ PATCH]: Fix 383
- Organization: Codesourcery LLC
Hi,
this fixes bug 383 where we failed to find a templated conversion operator
to reference type.
[14.8.2.3] 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?
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-12-26 Nathan Sidwell <nathan@codesourcery.com>
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). */
+ if (TREE_CODE (*arg) == REFERENCE_TYPE
+ && TREE_CODE (*parm) == REFERENCE_TYPE)
+ return 0;
break;
}
// { dg-do compile }
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@nathan@codesourcery.com>
// 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>& ()
{
SubjTop&t=*this;
return static_cast<Subj1<AS_TF>&>(t);
}
};
int
main(void)
{
typedef Subj1<FlagYes> Subj1Yes;
typedef Subj1<FlagNo> Subj1No;
Subj1Yes x;
Subj1No&y=x; // got bogus error
return 0;
}