diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9732e3b78c7..1c0759edcae 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10154,6 +10154,8 @@ finish_template_variable (tree var, tsubst_flags_t complain) 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)) { diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-err2.C b/gcc/testsuite/g++.dg/cpp2a/concepts-err2.C new file mode 100644 index 00000000000..c0372a6096b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-err2.C @@ -0,0 +1,11 @@ +// PR c++/95735 +// { dg-do compile { target concepts } } + +template + requires requires { F(); } +bool v{}; + +void f() { + int x; + static_assert(v<[&] { x++; }>); // { dg-error "not a constant expression" } +}