Re: Does libstdc++-16 stabilize the C++20 ABI?

Jonathan Wakely via Gcc-help <[email protected]> Mon, 27 Apr 2026 16:21:34 +0100
Newsgroups gmane.comp.gcc.help
Message-ID <CAH6eHdSs0mRatRfpbQc52ajc_eSwdn8iNZhHd3uRMvdHyLUz5A@mail.gmail.com>
On Mon, 27 Apr 2026 at 15:02, Daniel Grunwald via Gcc-help
<[email protected]> wrote:
>
> I found some contradictory information:
>
> <https://gcc.gnu.org/projects/cxx-status.html#cxx20> claims yes:
>  > Some C++20 features are available since GCC 8, but support was
>  > experimental and the ABI of C++20 features was not stable until
>  > GCC 16. C++20 modules support is still experimental.
>
> But <https://gcc.gnu.org/gcc-16/changes.html#libstdcxx> claims the opposite:
>  > As with all experimental support, programs using C++20 components
>  > should assume that those components are not compatible between
>  > different major releases.
>
> Can you clarify?

C++20 is stable in GCC 16, I sent a patch to update it which has not
been pushed yetL
https://gcc.gnu.org/pipermail/gcc-patches/2026-April/713215.html



>
>
> Additionally, let me ask about a concrete scenario:
>
> 1. We build a shared library with `g++-16 -std=c++20 -fvisibility=hidden`
> 2. The public headers for our library only use C++17 features (and we
> test that C++17 code can consume our library)
> 3. This library ends up being used in an application compiled with
> g++-17 and running with libstdc++-17 (or maybe even with a version
> further in the future).
>
> In this scenario, it seems to me that the interface between our shared
> library and the application does not care about the ABI stability of
> C++20 types, since those are not involved in the interface. C++20 types
> only matter for the stability of the interface between our shared
> library and libstdc++.so.6.

Correct.

The objects in your library that are built with GCC 16 mean that the
application must use libstdc++.so.6.0.35 (or later) which is true
whatever -std option you use.

Because you used -std=c++20, any objects in the entire application
that use -std=c++20 must be built with GCC 16 (or later) because e.g.
std::format in GCC 16 is not compatible with std::format in GCC 15.

See https://stackoverflow.com/a/49119902/981959 for more info.


> Does this mean our library could use experimental language versions
> (e.g. C++23) right now? Or is the libstdc++.so.6 ABI stability also
> restricted to stabilized language versions? I was not able to find any
> documentation on this. In particular, I checked
> <https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html> but that
> makes no mention of experimental language versions.

There are no C++23 symbols in libstdc++.so, precisely so that the
question of their stability doesn't matter. Any non-inline C++23
symbols are in the libstdc++exp.a static lib, not in libstdc++.so.

If you use -std=c++23 for any objects in your library, you need to use
the same version of GCC to compile all of those objects. Because the
C++23 components in GCC 16 might not be compatible with the C++23
components in GCC 15 or GCC 17.