]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/84489 - dependent default template argument
authorJason Merrill <jason@redhat.com>
Fri, 2 Mar 2018 18:24:40 +0000 (13:24 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 2 Mar 2018 18:24:40 +0000 (13:24 -0500)
* pt.c (type_unification_real): Handle early substitution failure.

From-SVN: r258152

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/fntmpdefarg7.C [new file with mode: 0644]

index d30784fbf1561159ddae219e0213e8925b6bf3e7..ab5a911f44ffb4477b3c6409494bf42436ae5810 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-02  Jason Merrill  <jason@redhat.com>
+
+       PR c++/84489 - dependent default template argument
+       * pt.c (type_unification_real): Handle early substitution failure.
+
 2018-02-28  Jason Merrill  <jason@redhat.com>
 
        PR c++/71784 - ICE with ref-qualifier and explicit specialization.
index 9dbf17ba4d883cc9250f59e250f42d107718e914..27e4c84ac79994a0377808bb1b47a1b848524e2f 100644 (file)
@@ -18603,10 +18603,10 @@ type_unification_real (tree tparms,
          if (DECL_P (parm))
            input_location = DECL_SOURCE_LOCATION (parm);
          arg = tsubst_template_arg (arg, targs, complain, NULL_TREE);
-         if (!uses_template_parms (arg))
+         if (arg != error_mark_node && !uses_template_parms (arg))
            arg = convert_template_argument (parm, arg, targs, complain,
                                             i, NULL_TREE);
-         else if (saw_undeduced < 2)
+         else if (saw_undeduced == 1)
            arg = NULL_TREE;
          else
            arg = error_mark_node;
diff --git a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg7.C b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg7.C
new file mode 100644 (file)
index 0000000..636bf1a
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/84489
+// { dg-do compile { target c++11 } }
+
+template <class T = int, T N = T(), bool B = (N >> 1)>
+T f1() {return 0;}
+
+int main()
+{
+  f1(); // Bug here
+}