https://gcc.gnu.org/g:4a514ea759f6045ef091504f2afcf4b618fe2639
commit r16-7259-g4a514ea759f6045ef091504f2afcf4b618fe2639 Author: Jakub Jelinek <[email protected]> Date: Tue Feb 3 14:22:46 2026 +0100 libstdc++: Define __cpp_lib_define_static [PR123921] I've totally missed the P3491R3 paper (define_static_{string,object,array}) comes with its own feature test macro - __cpp_lib_define_static 202506 which should appear in <version> and <meta>. The paper contains 3 parts, std::is_string_literal, std::meta::reflect_constant_{string,array} and std::define_static_{string,object,array}. The first part is implementable without reflection, the third part in theory would be also implementable without reflection but usually will be (and in libstdc++ is) implemented using reflection, and the middle part is really part of reflection. So dunno how useful this FTM actually is, maybe just for cases where some implementation does implement reflection and doesn't implement this paper for a while. Anyway, the FTM is in C++26 draft, so this patch adds it, with the same condition as __cpp_lib_reflection. 2026-02-03 Jakub Jelinek <[email protected]> PR libstdc++/123921 * include/bits/version.def (define_static): New with the same values as reflection. * include/bits/version.h: Regenerate. * include/std/meta: Define also __glibcxx_want_define_static before including bits/version.h. * g++.dg/reflect/feat2.C: Add also test for __cpp_lib_define_static. * g++.dg/reflect/feat3.C: New test. Diff: --- gcc/testsuite/g++.dg/reflect/feat2.C | 6 ++++++ gcc/testsuite/g++.dg/reflect/feat3.C | 17 +++++++++++++++++ libstdc++-v3/include/bits/version.def | 10 ++++++++++ libstdc++-v3/include/bits/version.h | 10 ++++++++++ libstdc++-v3/include/std/meta | 1 + 5 files changed, 44 insertions(+) diff --git a/gcc/testsuite/g++.dg/reflect/feat2.C b/gcc/testsuite/g++.dg/reflect/feat2.C index 902732b08247..dc4c82cdaab9 100644 --- a/gcc/testsuite/g++.dg/reflect/feat2.C +++ b/gcc/testsuite/g++.dg/reflect/feat2.C @@ -9,3 +9,9 @@ #elif __cpp_lib_reflection != 202506 # error "__cpp_lib_reflection != 202506" #endif + +#ifndef __cpp_lib_define_static +# error "__cpp_lib_define_static" +#elif __cpp_lib_define_static != 202506 +# error "__cpp_lib_define_static != 202506" +#endif diff --git a/gcc/testsuite/g++.dg/reflect/feat3.C b/gcc/testsuite/g++.dg/reflect/feat3.C new file mode 100644 index 000000000000..68b72e27f39b --- /dev/null +++ b/gcc/testsuite/g++.dg/reflect/feat3.C @@ -0,0 +1,17 @@ +// { dg-do compile { target c++26 } } +// { dg-additional-options "-freflection" } +// Test feature test macros. + +#include <meta> + +#ifndef __cpp_lib_reflection +# error "__cpp_lib_reflection" +#elif __cpp_lib_reflection != 202506 +# error "__cpp_lib_reflection != 202506" +#endif + +#ifndef __cpp_lib_define_static +# error "__cpp_lib_define_static" +#elif __cpp_lib_define_static != 202506 +# error "__cpp_lib_define_static != 202506" +#endif diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def index 8c5f4bb7c4c5..ba0ef5aecfdc 100644 --- a/libstdc++-v3/include/bits/version.def +++ b/libstdc++-v3/include/bits/version.def @@ -2271,6 +2271,16 @@ ftms = { }; }; +ftms = { + name = define_static; + values = { + v = 202506; + cxxmin = 26; + extra_cond = "__cpp_impl_reflection >= 202506L"; + cxx11abi = yes; + }; +}; + ftms = { name = is_implicit_lifetime; values = { diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h index 985701447bee..74d1a28f75c4 100644 --- a/libstdc++-v3/include/bits/version.h +++ b/libstdc++-v3/include/bits/version.h @@ -2546,6 +2546,16 @@ #endif /* !defined(__cpp_lib_reflection) */ #undef __glibcxx_want_reflection +#if !defined(__cpp_lib_define_static) +# if (__cplusplus > 202302L) && _GLIBCXX_USE_CXX11_ABI && (__cpp_impl_reflection >= 202506L) +# define __glibcxx_define_static 202506L +# if defined(__glibcxx_want_all) || defined(__glibcxx_want_define_static) +# define __cpp_lib_define_static 202506L +# endif +# endif +#endif /* !defined(__cpp_lib_define_static) */ +#undef __glibcxx_want_define_static + #if !defined(__cpp_lib_is_implicit_lifetime) # if (__cplusplus >= 202100L) && (__has_builtin(__builtin_is_implicit_lifetime)) # define __glibcxx_is_implicit_lifetime 202302L diff --git a/libstdc++-v3/include/std/meta b/libstdc++-v3/include/std/meta index 033746a40349..59a678037a16 100644 --- a/libstdc++-v3/include/std/meta +++ b/libstdc++-v3/include/std/meta @@ -34,6 +34,7 @@ #endif #define __glibcxx_want_reflection +#define __glibcxx_want_define_static #include <bits/version.h> #if __glibcxx_reflection >= 202506L // C++ >= 26 && __cpp_impl_reflection
