This ICE-on-invalid goes back to GCC 6. In finish_template_variable,
if coerce_innermost_template_parms returns error_mark_node, we pass
it down to constraints_satisfied_p and that error_mark_node flows
down to various satisfy_* functions and then to various tsubst_*
functions, where we crash. diagnose_constraints also doesn't cope
with error arglist, so I think we should just return as in the
patch below.
gcc/cp/ChangeLog:
PR c++/95735
* pt.c (finish_template_variable): Return if
coerce_innermost_template_parms return error_mark_node.
gcc/testsuite/ChangeLog:
PR c++/95735
* g++.dg/cpp2a/concepts-err2.C: New test.
arglist = coerce_innermost_template_parms (parms, arglist, templ, complain,
/*req_all*/true,
/*use_default*/true);
+ if (arglist == error_mark_node)
+ return error_mark_node;
if (flag_concepts && !constraints_satisfied_p (templ, arglist))
{
--- /dev/null
+// PR c++/95735
+// { dg-do compile { target concepts } }
+
+template <auto F>
+ requires requires { F(); }
+bool v{};
+
+void f() {
+ int x;
+ static_assert(v<[&] { x++; }>); // { dg-error "not a constant expression" }
+}