https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96926

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Further reduced:

template <typename T> struct A {
  using type = typename T::type;
};
template <typename U> class B {
  template <typename V = int,
            typename A<V>::type X>
  B(U);
};
struct C {
  B<int> b;
  C();
};
int main() {
  C c;
}

We run into trouble trying to implicitly declare the copy constructor for C,
which involves overload resolution to find the constructor called for copying
B<int>.

After r262172, when we consider the constructor template, we try to substitute
the default template argument for V into the type of X, which involves
instantiating A<int>, which fails.  Before r262172, we would see that we can't
convert B<int> to int, and give up on the candidate before getting to this
substitution.  But r262172 moves the convertibility checking until after we're
done with deduction, as per http://wg21.link/cwg2369

I think perhaps it's wrong to do substitution at this point because X has no
default argument.  Giving it a default argument causes clang 10 to also reject
the testcase.

Reply via email to