From: Jason Merrill Date: Thu, 5 Mar 2020 18:45:38 +0000 (-0500) Subject: c++: Avoid ICE on infinite recursion with concepts. X-Git-Tag: releases/gcc-9.3.0~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e50627ff8cd54c3983614b34727323b333b9374d;p=thirdparty%2Fgcc.git c++: Avoid ICE on infinite recursion with concepts. This was simple enough to backport even though it's concepts. gcc/cp/ChangeLog 2020-03-05 Jason Merrill PR c++/88395 PR c++/93551 * constraint.cc (constraints_satisfied_p): Use push_tinst_level. --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 437df4d0829a..c697ff3a4421 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-03-05 Jason Merrill + + PR c++/88395 + PR c++/93551 + * constraint.cc (constraints_satisfied_p): Use push_tinst_level. + 2020-03-05 Martin Sebor Backport from trunk. diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 9884eb0db50e..cbd9c141809b 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -2390,7 +2390,11 @@ constraints_satisfied_p (tree decl) ci = get_constraints (decl); } + if (!push_tinst_level (decl)) + return true; tree eval = satisfy_associated_constraints (ci, args); + pop_tinst_level (); + return eval == boolean_true_node; } diff --git a/gcc/testsuite/g++.dg/concepts/concepts-pr88395.C b/gcc/testsuite/g++.dg/concepts/concepts-pr88395.C new file mode 100644 index 000000000000..da5834bcc073 --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/concepts-pr88395.C @@ -0,0 +1,23 @@ +// { dg-options "-std=c++17 -fconcepts" } + +template +concept Concept2 = requires (T t, U u) +{ + t += u; // { dg-error "template instantiation depth" } +}; + +template +concept Concept = Concept2 ; + +struct S +{ + template + constexpr S& operator += (T o); +}; + +constexpr S operator * (S a, S b) +{ + return a += b; +} + +// { dg-prune-output "compilation terminated" }