On Tue, Feb 3, 2026 at 9:03 AM Jakub Jelinek <[email protected]> wrote:

> Hi!
>
> 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.
>
The story is two fold, this paper initially started with define_static_*,
and it was
observed that these are not really tied to reflection (thus std namespace),
later
reflect_constant_* were added, and they become entangled together.

So yes, I agree this is only relevant for compilers that would get the main
reflection
paper, but not these functions.

> Anyway, the FTM is in C++26 draft, so this patch adds it, with the same
> condition as __cpp_lib_reflection.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
LGTM. Jonathan still needs to approve.

>
> 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.
>
> --- libstdc++-v3/include/bits/version.def.jj    2026-01-28
> 09:34:32.799242560 +0100
> +++ libstdc++-v3/include/bits/version.def       2026-02-02
> 11:56:42.186951034 +0100
> @@ -2272,6 +2272,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 = {
>      v =  202302;
> --- libstdc++-v3/include/bits/version.h.jj      2026-01-28
> 09:34:32.799242560 +0100
> +++ libstdc++-v3/include/bits/version.h 2026-02-02 11:56:49.231954047 +0100
> @@ -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
> --- libstdc++-v3/include/std/meta.jj    2026-01-15 16:33:47.022097704 +0100
> +++ libstdc++-v3/include/std/meta       2026-02-02 11:57:24.436237366 +0100
> @@ -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
> --- gcc/testsuite/g++.dg/reflect/feat2.C.jj     2026-01-15
> 16:33:47.008097942 +0100
> +++ gcc/testsuite/g++.dg/reflect/feat2.C        2026-02-02
> 11:58:52.250754011 +0100
> @@ -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
> --- gcc/testsuite/g++.dg/reflect/feat3.C.jj     2026-02-02
> 11:58:59.463632171 +0100
> +++ gcc/testsuite/g++.dg/reflect/feat3.C        2026-02-02
> 11:59:07.636494114 +0100
> @@ -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
>
>         Jakub
>
>

Reply via email to