+2020-03-03 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-03 Jakub Jelinek <jakub@redhat.com>
PR c++/93998
int levels;
tree arg = NULL_TREE;
- /* Early in template argument deduction substitution, we don't
- want to reduce the level of 'auto', or it will be confused
- with a normal template parm in subsequent deduction. */
- if (is_auto (t) && (complain & tf_partial))
- return t;
-
r = NULL_TREE;
gcc_assert (TREE_VEC_LENGTH (args) > 0);
about the template parameter in question. */
return t;
+ /* Early in template argument deduction substitution, we don't
+ want to reduce the level of 'auto', or it will be confused
+ with a normal template parm in subsequent deduction.
+ Similarly, 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. */
+2020-03-03 Marek Polacek <polacek@redhat.com>
+
+ PR c++/90505 - mismatch in template argument deduction.
+ * g++.dg/template/deduce4.C: New test.
+ * g++.dg/template/deduce5.C: New test.
+ * g++.dg/template/deduce6.C: New test.
+ * g++.dg/template/deduce7.C: New test.
+
2020-03-03 Jakub Jelinek <jakub@redhat.com>
PR c++/93998
--- /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...);
+};