[PATCH] libstdc++: Implement LWG 4440 feature-test macros added to <iosfwd>

Tomasz Kaminski tkaminsk@redhat.com
Fri Jul 31 13:18:06 GMT 2026


On Fri, Jul 31, 2026 at 3:14 PM Patrick Palka <ppalka@redhat.com> wrote:

> Tested on x86_64-pc-linux-gnu, does this look OK for trunk and
> backports?
>
> -- >8 --
>
> Note __cpp_lib_char8_t doesn't use the <bits/version.h> mechanism, it's
> defined in c++config and thus provided by all headers by default.
>
> libstdc++-v3/ChangeLog:
>
>         * include/std/iosfwd: Provide feature-test macros
>         __cpp_lib_spanstream and __cpp_lib_syncbuf.
>         * testsuite/27_io/headers/iosfwd/synopsis.cc: Verify values
>         of these FTMs.
> ---
>  libstdc++-v3/include/std/iosfwd                         | 4 ++++
>  libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc | 8 ++++++++
>  2 files changed, 12 insertions(+)
>
> diff --git a/libstdc++-v3/include/std/iosfwd
> b/libstdc++-v3/include/std/iosfwd
> index 1d5e684b53bb..511b2f3a23f1 100644
> --- a/libstdc++-v3/include/std/iosfwd
> +++ b/libstdc++-v3/include/std/iosfwd
> @@ -39,6 +39,10 @@
>
>  #include <bits/requires_hosted.h> // iostreams
>
> +#define __glibcxx_want_spanstream
> +#define __glibcxx_want_syncbuf
> +#include <bits/version.h>
> +
>    /**
>     *  @defgroup io I/O
>     *
> diff --git a/libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc
> b/libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc
> index 8d9501f42ef4..f39a0b95a3d6 100644
> --- a/libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc
> +++ b/libstdc++-v3/testsuite/27_io/headers/iosfwd/synopsis.cc
> @@ -3,6 +3,14 @@
>
>  #include <iosfwd>
>
> +#if __cplusplus >= 202202L && __cpp_lib_spanstream != 202106L
> +# error "Feature-test macro __cpp_lib_spanstrean has wrong value in
> <iosfwd>"
> +#endif
>
I would test that __cpp_lib_char8_t is defined when you include this
header, even
if it is for all headers.


> +
> +#if __cplusplus >= 202002L && __cpp_lib_syncbuf != 201803L
> +# error "Feature-test macro __cpp_lib_syncbuf has wrong value in <iosfwd>"
> +#endif
> +
>  namespace std
>  {
>    // [iosfwd.syn]
> --
> 2.55.0.481.ga97fcc37c2
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20260731/2ec91e85/attachment.htm>


More information about the Libstdc++ mailing list