[PATCH] libstdc++: Define __cpp_lib_stdbit_h and __cpp_lib_stdckdint_h feature test macros.

Tomasz Kaminski tkaminsk@redhat.com
Thu Apr 16 07:53:02 GMT 2026


On Tue, Apr 14, 2026 at 4:43 PM Jonathan Wakely <jwakely@redhat.com> wrote:

> On Tue, 14 Apr 2026 at 15:39, Tomasz Kamiński <tkaminsk@redhat.com> wrote:
> >
> > This implements LWG4550: Need new feature test macros for <stdckdint.h>
> > and <stdbit.h>.
> >
> > libstdc++-v3/ChangeLog:
> >
> >         * include/bits/version.def (stdbit_h, stdckdint_h): Define.
> >         * include/bits/version.h: Regenerate.
> >         * include/c_compatibility/stdbit.h (__cpp_lib_stdbit_h): Define
> >         and use it in guards.
> >         * include/c_compatibility/stdckdint.h (__cpp_lib_stdckdint_h):
> >         Define and use it in guards.
> > ---
> > Testing on x86_64-linux. Dedicated tests 20_util/stdbit* and
> 26_numerics/stdckint*
> > already passes, so valus seem correct.
>
> OK. We should backport this to GCC 15 at some point too.
>
Backported to GCC15.

>
>
> >
> >  libstdc++-v3/include/bits/version.def         | 16 +++++++++++++++
> >  libstdc++-v3/include/bits/version.h           | 20 +++++++++++++++++++
> >  libstdc++-v3/include/c_compatibility/stdbit.h |  8 ++++++--
> >  .../include/c_compatibility/stdckdint.h       |  8 ++++++--
> >  4 files changed, 48 insertions(+), 4 deletions(-)
> >
> > diff --git a/libstdc++-v3/include/bits/version.def
> b/libstdc++-v3/include/bits/version.def
> > index 94fc1f85993..13dba4d6378 100644
> > --- a/libstdc++-v3/include/bits/version.def
> > +++ b/libstdc++-v3/include/bits/version.def
> > @@ -1871,6 +1871,22 @@ ftms = {
> >    };
> >  };
> >
> > +ftms = {
> > +  name = stdbit_h;
> > +  values = {
> > +    v = 202603;
> > +    cxxmin = 26;
> > +  };
> > +};
> > +
> > +ftms = {
> > +  name = stdckdint_h;
> > +  values = {
> > +    v = 202603;
> > +    cxxmin = 26;
> > +  };
> > +};
> > +
> >  ftms = {
> >    name = adaptor_iterator_pair_constructor;
> >    values = {
> > diff --git a/libstdc++-v3/include/bits/version.h
> b/libstdc++-v3/include/bits/version.h
> > index 402e67580eb..743f7e29fe2 100644
> > --- a/libstdc++-v3/include/bits/version.h
> > +++ b/libstdc++-v3/include/bits/version.h
> > @@ -2076,6 +2076,26 @@
> >  #endif /* !defined(__cpp_lib_stdatomic_h) */
> >  #undef __glibcxx_want_stdatomic_h
> >
> > +#if !defined(__cpp_lib_stdbit_h)
> > +# if (__cplusplus >  202302L)
> > +#  define __glibcxx_stdbit_h 202603L
> > +#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_stdbit_h)
> > +#   define __cpp_lib_stdbit_h 202603L
> > +#  endif
> > +# endif
> > +#endif /* !defined(__cpp_lib_stdbit_h) */
> > +#undef __glibcxx_want_stdbit_h
> > +
> > +#if !defined(__cpp_lib_stdckdint_h)
> > +# if (__cplusplus >  202302L)
> > +#  define __glibcxx_stdckdint_h 202603L
> > +#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_stdckdint_h)
> > +#   define __cpp_lib_stdckdint_h 202603L
> > +#  endif
> > +# endif
> > +#endif /* !defined(__cpp_lib_stdckdint_h) */
> > +#undef __glibcxx_want_stdckdint_h
> > +
> >  #if !defined(__cpp_lib_adaptor_iterator_pair_constructor)
> >  # if (__cplusplus >= 202100L) && _GLIBCXX_HOSTED
> >  #  define __glibcxx_adaptor_iterator_pair_constructor 202106L
> > diff --git a/libstdc++-v3/include/c_compatibility/stdbit.h
> b/libstdc++-v3/include/c_compatibility/stdbit.h
> > index 1fb691e36c1..fa4ec0414c6 100644
> > --- a/libstdc++-v3/include/c_compatibility/stdbit.h
> > +++ b/libstdc++-v3/include/c_compatibility/stdbit.h
> > @@ -29,7 +29,11 @@
> >  #ifndef _GLIBCXX_STDBIT_H
> >  #define _GLIBCXX_STDBIT_H
> >
> > -#if __cplusplus > 202302L
> > +#define __glibcxx_want_stdbit_h
> > +#include <bits/version.h>
> > +
> > +#ifdef __cpp_lib_stdbit_h // C++ >= 26
> > +
> >  #include <bit>
> >
> >  #define __STDC_VERSION_STDBIT_H__ 202311L
> > @@ -577,6 +581,6 @@ _GLIBCXX_STDBIT_FUNC(stdc_bit_floor);
> >  _GLIBCXX_STDBIT_FUNC(stdc_bit_ceil);
> >  #undef _GLIBCXX_STDBIT_FUNC
> >  #endif // !DOXYGEN
> > -#endif // C++26
> > +#endif // __cpp_lib_stdbit_h
> >
> >  #endif // _GLIBCXX_STDBIT_H
> > diff --git a/libstdc++-v3/include/c_compatibility/stdckdint.h
> b/libstdc++-v3/include/c_compatibility/stdckdint.h
> > index 5bdf4dc7b24..0f0b30cc899 100644
> > --- a/libstdc++-v3/include/c_compatibility/stdckdint.h
> > +++ b/libstdc++-v3/include/c_compatibility/stdckdint.h
> > @@ -29,7 +29,11 @@
> >  #ifndef _GLIBCXX_STDCKDINT_H
> >  #define _GLIBCXX_STDCKDINT_H
> >
> > -#if __cplusplus > 202302L
> > +#define __glibcxx_want_stdckdint_h
> > +#include <bits/version.h>
> > +
> > +#ifdef __cpp_lib_stdckdint_h // C++ >= 26
> > +
> >  #include <type_traits>
> >  #include <concepts>
> >
> > @@ -96,6 +100,6 @@ using __gnu_cxx::ckd_sub;
> >  using __gnu_cxx::ckd_mul;
> >  #endif
> >
> > -#endif // C++26
> > +#endif // __cpp_lib_stdckdint_h
> >
> >  #endif // _GLIBCXX_STDCKDINT_H
> > --
> > 2.53.0
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20260416/aee743af/attachment-0001.htm>


More information about the Libstdc++ mailing list