]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/38950 (ICE: deducing function template arguments for array type.)
authorJason Merrill <jason@redhat.com>
Tue, 17 Feb 2009 18:27:32 +0000 (13:27 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 17 Feb 2009 18:27:32 +0000 (13:27 -0500)
        PR c++/38950
        * pt.c (unify)[TEMPLATE_PARM_INDEX]: Convert to the tsubsted type.

From-SVN: r144239

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

index d509ced7ff9a1c9e29a2295815e59b9041342736..6b267b9343b16ef01520ffc97fcae1b7da6ca437 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-17  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38950
+       * pt.c (unify)[TEMPLATE_PARM_INDEX]: Convert to the tsubsted type.
+
 2009-02-13  Jason Merrill  <jason@redhat.com>
 
        PR c++/39070
index 737a9a69af6278dbfb9a2f161e3fed7d5a4a4be3..7eaf68b18d893f1efaa6d666a2f09e254ab15434 100644 (file)
@@ -13058,7 +13058,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict)
        /* Convert the ARG to the type of PARM; the deduced non-type
           template argument must exactly match the types of the
           corresponding parameter.  */
-       arg = fold (build_nop (TREE_TYPE (parm), arg));
+       arg = fold (build_nop (tparm, arg));
       else if (uses_template_parms (tparm))
        /* We haven't deduced the type of this parameter yet.  Try again
           later.  */
index dd8a030b82e2d6ccf78aafdf1ce8a12499ea30ca..21b482e742c59ef00892d90386b9228508a5ea03 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-17  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38950
+       * g++.dg/template/array20.C: New test.
+
 2009-02-17  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/35446
diff --git a/gcc/testsuite/g++.dg/template/array20.C b/gcc/testsuite/g++.dg/template/array20.C
new file mode 100644 (file)
index 0000000..2e5c1e3
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/38950
+
+template <typename T, T N> void f(T(&)[N]);
+
+int main() {
+    int x[2];
+    unsigned int y[2];
+    f(x); // works
+    f(y); // ICE
+}