+2020-03-04 Jason Merrill <jason@redhat.com>
+ Marek Polacek <polacek@redhat.com>
+
+ PR c++/90505 - mismatch in template argument deduction.
+ * pt.c (tsubst): Don't reduce the template level of template
+ parameters when tf_partial.
+
2020-03-04 Jason Merrill <jason@redhat.com>
PR c++/90432
about the template parameter in question. */
return t;
+ /* Like with 'auto', don't reduce the level of template parameters
+ to avoid mismatches when deducing their types. */
+ if (complain & tf_partial)
+ return t;
+
/* If we get here, we must have been looking at a parm for a
more deeply nested template. Make a new version of this
template parameter, but with a lower level. */
--- /dev/null
+// PR c++/90505 - mismatch in template argument deduction.
+// { dg-do compile }
+
+template <typename T>
+struct S {
+ template <typename U, typename V>
+ static void foo(V) { }
+
+ void bar () { foo<int>(10); }
+};
+
+void
+test ()
+{
+ S<int> s;
+ s.bar ();
+}
--- /dev/null
+// PR c++/90505 - mismatch in template argument deduction.
+// { dg-do compile { target c++11 } }
+
+template <typename T>
+struct S {
+ template <typename U, typename V = void>
+ static void foo(U) { }
+
+ void bar () { foo<int>(10); }
+};
+
+void
+test ()
+{
+ S<int> s;
+ s.bar ();
+}
--- /dev/null
+// PR c++/90505 - mismatch in template argument deduction.
+// { dg-do compile { target c++11 } }
+
+template <typename T>
+struct S {
+ template <typename U = int, typename V>
+ static void foo(V) { }
+
+ void bar () { foo<>(10); }
+};
+
+void
+test ()
+{
+ S<int> s;
+ s.bar ();
+}
--- /dev/null
+// PR c++/90505 - mismatch in template argument deduction.
+// { dg-do compile { target c++11 } }
+
+template <typename> class a {
+ using b = int;
+ using c = int;
+ b d;
+ void e() { g<c>(d); }
+ template <typename... f> static void g(f...);
+};