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]

Re: [C++ PATCH,committed] Fix PR17344 (missing tf_error check incoerce_template_parms)


Mark Mitchell wrote:

I'm not convinced this is the right fix.


Checks against tf_error should be done only for those cases specifically listed in the standard in the section on SFINAE. It is not the case that no errors should be issued when tf_error is set. It is merely the case that if either template argument-deduction or checking fails, then SFINAE applies. I see no evidence that this case is such a situation. Can you justify that? If not, please revert your patch.



Furthermore, this kind of patch is *never obvious*. Please get a review on all such patches in future.



This bug is indeed template argument deduction problem. For the testcase
below, we first determine if 'int bar(S)' is a viable candidate by checking if 'A<int>' can be converted to 'S' via the template constructor. Here
we can deduce 'X' to 'A' (with current GCC template template parameter
matching) and proceed to check if 'A<void>' is valid. However the
default argument 'intTraits<void>::i' in 'A<void>' fails the condition


 Attempting to use a type in the
 qualifier portion of a qualified name that names a type when that type
 does not contain the specified member, ...

I believe this is the only case we have failure when tsubst'ing the
default arugment. For all other cases not involving template template
parameter, the argument should already filled with default arguments
during parsing stage (with tf_error set) and the GCC behavior are not affected by my patch.



About the template template parameter matching, we could have this
mode of operation in the future, based the variadic template idea already proposed, i.e.


 // X can matches template class with one or more parameters
 template <template <typename, ...> class X> S(X<void>);

(I'll float the idea to comp.std.c++ later.)


Do you still want me to revert the patch?


--Kriang



Test case for PR17344:

template <class> struct intTraits;

template<> struct intTraits<int> { static const int i = 0; };

template<typename E, E i = intTraits<E>::i> struct A {};

struct S { template <template <typename> class X> S(X<void>); };

int bar(S); int bar(A<int,0>);

A<int> bed; + int i = bar(bed);





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