re PR c++/38950 (ICE: deducing function template arguments for array type.)
authorJason Merrill <jason@redhat.com>
Thu, 12 Feb 2009 22:40:37 +0000 (17:40 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 12 Feb 2009 22:40:37 +0000 (17:40 -0500)
        PR c++/38950
        * pt.c (unify)[TEMPLATE_PARM_INDEX]: Convert to the tsubsted type.

From-SVN: r144139

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

index 7a764b1..7ead4b2 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-12  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38950
+       * pt.c (unify)[TEMPLATE_PARM_INDEX]: Convert to the tsubsted type.
+
 2009-02-11  Jason Merrill  <jason@redhat.com>
 
        PR c++/39153
index 3176dc2..db8886c 100644 (file)
@@ -13457,7 +13457,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 7b68c65..5a940ef 100644 (file)
@@ -1,3 +1,8 @@
+2009-02-12  Jason Merrill  <jason@redhat.com>
+
+       PR c++/38950
+       * g++.dg/template/array20.C: New test.
+
 2009-02-12  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.dg/torture/fp-int-convert-float128-timode.c: Do not check
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
+}