https://gcc.gnu.org/g:30992707103392fbe55b972a09fa6497cf3157e3
commit r17-4231-g30992707103392fbe55b972a09fa6497cf3157e3 Author: Marek Polacek <[email protected]> Date: Mon Aug 24 15:07:25 2026 -0400 c++: function wrongly regarded immediate-escalating [PR126970] This should fail: using info = decltype(^^void); struct M { info i = ^^int; M(); }; M::M() = default; because CWG 3153 added "non-user-provided", and a function defaulted on a declaration other than its first is user-provided. PR c++/126970 gcc/cp/ChangeLog: * cp-gimplify.cc (immediate_escalating_function_p): Check !user_provided_p. gcc/testsuite/ChangeLog: * g++.dg/reflect/cwg3153-2.C: New test. Reviewed-by: Jason Merrill <[email protected]> Diff: --- gcc/cp/cp-gimplify.cc | 4 ++-- gcc/testsuite/g++.dg/reflect/cwg3153-2.C | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc index c8f40413891b..0fc44592cd2c 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -507,9 +507,9 @@ immediate_escalating_function_p (tree fn) specifier */ if (LAMBDA_FUNCTION_P (fn)) return true; - /* -- a defaulted function that is not declared with the + /* -- a non-user-provided defaulted function that is not declared with the consteval specifier */ - if (DECL_DEFAULTED_FN (fn)) + if (DECL_DEFAULTED_FN (fn) && !user_provided_p (fn)) return true; /* -- a function that results from the instantiation of a templated entity defined with the constexpr specifier. */ diff --git a/gcc/testsuite/g++.dg/reflect/cwg3153-2.C b/gcc/testsuite/g++.dg/reflect/cwg3153-2.C new file mode 100644 index 000000000000..d5f30f1520a8 --- /dev/null +++ b/gcc/testsuite/g++.dg/reflect/cwg3153-2.C @@ -0,0 +1,10 @@ +// PR c++/126970 +// CWG3153 +// { dg-do compile { target c++26 } } +// { dg-additional-options "-freflection" } + +using info = decltype(^^void); +struct M { + info i = ^^int; M(); // { dg-error "consteval-only value outside an immediate function context" } +}; +M::M() = default;
