C++ PATCH for c++/86098, ICE with template template parameter placeholder

Message ID CADzB+2nurwXG4PsgbY0jfZRDrE04wH-KX25sDxgNJTBbiBJvQw@mail.gmail.com
State New
Headers show
Series
  • C++ PATCH for c++/86098, ICE with template template parameter placeholder
Related show

Commit Message

Jason Merrill June 13, 2018, 3:32 a.m.
When comparing two TEMPLATE_TYPE_PARM, we need to consider whether
they are acting as placeholders for templates.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 10e5cb6bf4c605741ef59f17120304a3c261c06c
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Jun 12 22:38:07 2018 -0400

            PR c++/86098 - ICE with template placeholder for TTP.
    
            * typeck.c (structural_comptypes) [TEMPLATE_TYPE_PARM]: Check
            CLASS_PLACEHOLDER_TEMPLATE.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 9febdb908ae..b033afd9884 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1375,6 +1375,11 @@  structural_comptypes (tree t1, tree t2, int strict)
 	 template parameters set, they can't be equal.  */
       if (!comp_template_parms_position (t1, t2))
 	return false;
+      /* If T1 and T2 don't represent the same class template deduction,
+         they aren't equal.  */
+      if (CLASS_PLACEHOLDER_TEMPLATE (t1)
+	  != CLASS_PLACEHOLDER_TEMPLATE (t2))
+	return false;
       /* Constrained 'auto's are distinct from parms that don't have the same
 	 constraints.  */
       if (!equivalent_placeholder_constraints (t1, t2))
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction58.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction58.C
new file mode 100644
index 00000000000..82c3f83710f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction58.C
@@ -0,0 +1,16 @@ 
+// PR c++/86098
+// { dg-additional-options -std=c++17 }
+
+template <class _Res> class future;
+template <class T> T&& declval();
+
+template<template <class...> class T>
+struct construct_deduced {
+  template <class... AN>
+  using deduced_t = decltype(T{declval<AN>()...});
+  template<class... AN>
+  deduced_t<AN...> operator()(AN&&... an) const;
+};
+
+template<class T>
+future<T> future_from(T singleSender);