From: Patrick Palka Date: Tue, 17 Feb 2026 16:21:45 +0000 (-0500) Subject: c++: void(concept-id) evaluation [PR121822] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44a51e8c7037eacd4315df0e84bf51e6e4021088;p=thirdparty%2Fgcc.git c++: void(concept-id) evaluation [PR121822] Similar to r16-7056-g22f51c0f5e62a4, here the expression within the decltype void(Derived) is non-dependent enough that we instantiate/fold it immediately, during which however convert_to_void tries to evaluate the concept-id, which fails. When in an unevaluated context such as decltype I don't think convert_to_void should be evaluating concept-ids. PR c++/121822 gcc/cp/ChangeLog: * cvt.cc (convert_to_void): Don't evaluate a concept-id in an unevaluated context. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-decltype6.C: New test. Reviewed-by: Jason Merrill --- diff --git a/gcc/cp/cvt.cc b/gcc/cp/cvt.cc index fe9b9dc6dd1..4042938da5e 100644 --- a/gcc/cp/cvt.cc +++ b/gcc/cp/cvt.cc @@ -1210,7 +1210,7 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain) /* Explicitly evaluate void-converted concept checks since their satisfaction may produce ill-formed programs. */ - if (concept_check_p (expr)) + if (concept_check_p (expr) && !cp_unevaluated_operand) expr = evaluate_concept_check (expr); /* Detect using expressions of consteval-only types outside manifestly diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-decltype6.C b/gcc/testsuite/g++.dg/cpp2a/concepts-decltype6.C new file mode 100644 index 00000000000..03ecc7b0a07 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-decltype6.C @@ -0,0 +1,16 @@ +// PR c++/121822 +// { dg-do compile { target c++20 } } + +template +using void_t = void; + +template +concept Derived = requires { typename T::derived_type; }; + +template +struct Wrapper; + +template +struct Wrapper))>> { }; + +Wrapper x;