===================================================================
@@ -18826,6 +18826,13 @@ get_class_bindings (tree tmpl, tree tparms, tree s
if (! TREE_VEC_ELT (innermost_deduced_args, i))
return NULL_TREE;
+ tree tinst = build_tree_list (tmpl, args);
+ if (! push_tinst_level (tinst))
+ {
+ ggc_free (tinst);
+ return NULL_TREE;
+ }
+
/* Verify that nondeduced template arguments agree with the type
obtained from argument deduction.
@@ -18839,6 +18846,9 @@ get_class_bindings (tree tmpl, tree tparms, tree s
`T' is `A' but unify () does not check whether `typename T::X'
is `int'. */
spec_args = tsubst (spec_args, deduced_args, tf_none, NULL_TREE);
+
+ pop_tinst_level ();
+
spec_args = coerce_template_parms (DECL_INNERMOST_TEMPLATE_PARMS (tmpl),
spec_args, tmpl,
tf_none, false, false);
===================================================================
@@ -0,0 +1,25 @@
+// PR c++/58059
+// { dg-do compile { target c++11 } }
+
+template<bool, typename T = void> struct enable_if { typedef T type; };
+template<typename T> struct enable_if<false, T> { };
+
+// This code is nonsense; it was produced by minimizing the problem repeatedly.
+constexpr bool test_func(int value) {
+ return true;
+}
+template <int TParm, class Enable=void>
+struct test_class {
+ static constexpr int value = 0;
+};
+template <int TParm>
+struct test_class<
+ TParm,
+ // This line ultimately causes the crash.
+ typename enable_if<test_func(test_class<TParm-1>::value)>::type // { dg-error "depth exceeds" }
+ > {
+ static constexpr int value = 1;
+};
+
+// This instantiation is required in order to crash.
+template class test_class<2,void>;
===================================================================
@@ -5,9 +5,7 @@ template <int I> struct F
{
int operator()()
{
- F<I+1> f; // { dg-error "incomplete type" "incomplete" }
- // { dg-bogus "exceeds maximum.*exceeds maximum" "exceeds" { xfail *-*-* } 8 }
- // { dg-error "exceeds maximum" "exceeds" { xfail *-*-* } 8 }
+ F<I+1> f; // { dg-error "depth exceeds|incomplete" }
return f()*I; // { dg-message "recursively" "recurse" }
}
};
===================================================================
@@ -0,0 +1,5 @@
+// PR c++/51488
+
+template<class T,class U=void> struct s;
+template<class T> struct s<T,typename s<T>::a> {};
+s<int> ca; // { dg-error "depth exceeds|incomplete" }