* C++ PATCH for c++/44629 (ICE with function template as non-type template argument)
@ 2011-03-09 17:57 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2011-03-09 17:57 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 647 bytes --]
In this testcase, we have a function template used as an argument for a
function pointer template parameter. This causes unify to abort because
an OVERLOAD doesn't satisfy EXPR_P. 14.8.2.5 lists an overloaded
function given as a function argument as a non-deduced context, so it
seems reasonable to treat one given as a template argument as
non-deduced as well.
The ABI is silent on how to mangle this, and EDG currently does
something strange, so I'm not going to add mangling in 4.6; as a result,
the testcase will get a sorry from the mangler, but that's better than
an ICE.
Tested x86_64-pc-linux-gnu, applied to trunk, 4.4, 4.5.
[-- Attachment #2: 44629-partial.patch --]
[-- Type: text/plain, Size: 1154 bytes --]
commit 5faa2c811748d00cbee57ad0e5c991549099b95a
Author: Jason Merrill <jason@redhat.com>
Date: Tue Mar 8 21:44:29 2011 -0500
PR c++/44629
* pt.c (unify): An unresolved overload is a nondeduced context.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2ca2cd0..ac91698 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -15688,6 +15688,9 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict)
return 1;
default:
+ /* An unresolved overload is a nondeduced context. */
+ if (type_unknown_p (parm))
+ return 0;
gcc_assert (EXPR_P (parm));
/* We must be looking at an expression. This can happen with
diff --git a/gcc/testsuite/g++.dg/template/nontype22.C b/gcc/testsuite/g++.dg/template/nontype22.C
new file mode 100644
index 0000000..f2c8c46
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/nontype22.C
@@ -0,0 +1,11 @@
+// PR c++/44629
+// The proper mangling is unclear.
+
+template<typename T> int cmp1(T a, T b);
+template<typename T, int (*cmp)(T, T) = cmp1> struct A { };
+template <typename T> void f (A<T> &); // { dg-bogus "" "" { xfail *-*-* } }
+void g()
+{
+ A<char> a;
+ f(a);
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-03-09 17:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-09 17:57 C++ PATCH for c++/44629 (ICE with function template as non-type template argument) Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).