Here the problem was that in order to form a FUNCTION_DECL for foo<int> in
the uninstantiated template, we were trying to deduce template args for S
from the template parm itself, and failing.
Tested x86_64-pc-linux-gnu, applying to trunk.
* pt.c (do_class_deduction): Handle parm used as its own arg.
---
gcc/cp/pt.c | 3 +++
gcc/testsuite/g++.dg/cpp1z/class-deduction64.C | 9 +++++++++
gcc/cp/ChangeLog | 5 +++++
3 files changed, 17 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp1z/class-deduction64.C
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 8a5a0b38b2d..906cfe0a58c 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -27184,6 +27184,9 @@ do_class_deduction (tree ptype, tree tmpl, tree init,
int flags,
error ("non-class template %qT used without template arguments", tmpl);
return error_mark_node;
}
+ if (init && TREE_TYPE (init) == ptype)
+ /* Using the template parm as its own argument. */
+ return ptype;
tree type = TREE_TYPE (tmpl);
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C
b/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C
new file mode 100644
index 00000000000..3a06e6fb522
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction64.C
@@ -0,0 +1,9 @@
+// PR c++/88820
+// { dg-do compile { target c++17 } }
+
+template <int> struct S;
+
+template <S> struct W {
+ template <typename> static int foo();
+ bool b = foo<int>();
+};
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c2162a4a3d4..94e278dc944 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-03-07 Jason Merrill <[email protected]>
+
+ PR c++/88820 - ICE with CTAD and member template used in DMI.
+ * pt.c (do_class_deduction): Handle parm used as its own arg.
+
2019-03-07 Jakub Jelinek <[email protected]>
PR c++/89585
base-commit: f62ec1bb16cb7645d9bf6c981178d5e7b5e06ba2
--
2.20.1