https://gcc.gnu.org/g:f73ecaf1957d35a99909999735ebe228c8dd6188
commit r14-11178-gf73ecaf1957d35a99909999735ebe228c8dd6188 Author: Patrick Palka <ppa...@redhat.com> Date: Thu Jan 9 10:50:19 2025 -0500 c++: ICE during requires-expr partial subst [PR118060] Here during partial substitution of the requires-expression (as part of CTAD constraint rewriting) we segfault from the INDIRECT_REF case of convert_to_void due *f(u) being type-dependent. We should just defer checking convert_to_void until satisfaction. PR c++/118060 gcc/cp/ChangeLog: * constraint.cc (tsubst_valid_expression_requirement): Don't check convert_to_void during partial substitution. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-requires40.C: New test. Reviewed-by: Jason Merrill <ja...@redhat.com> (cherry picked from commit ca79349c050c27ff466735ba78d2e2bbce56ffdc) Diff: --- gcc/cp/constraint.cc | 4 +++- gcc/testsuite/g++.dg/cpp2a/concepts-requires40.C | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index b6c6a5e23306..cbf6357ad681 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -1993,7 +1993,9 @@ tsubst_valid_expression_requirement (tree t, tree args, sat_info info) { tsubst_flags_t quiet = info.complain & ~tf_warning_or_error; tree r = tsubst_expr (t, args, quiet, info.in_decl); - if (convert_to_void (r, ICV_STATEMENT, quiet) != error_mark_node) + if (r != error_mark_node + && (processing_template_decl + || convert_to_void (r, ICV_STATEMENT, quiet) != error_mark_node)) return r; if (info.diagnose_unsatisfaction_p ()) diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires40.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires40.C new file mode 100644 index 000000000000..918bab410f30 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires40.C @@ -0,0 +1,12 @@ +// PR c++/118060 +// { dg-do compile { target c++20 } } + +int* f(int); + +template<class T> +struct A { + template<class U> requires requires (U u) { *f(u); } + A(T, U); +}; + +A a{0, 0};