Open
Description
In C++23 onwards, <stdatomic.h>
#define
s _Atomic(T)
as std::atomic<T>
. This results in an ABI break when using libstdc++. Example:
#include <stdatomic.h>
struct A { int m, n; char c; };
static_assert(sizeof(_Atomic(A)) == 16);
When using Clang with libstdc++, the built-in _Atomic(A)
has size 16 but std::atomic<A>
has size 12 on for example x86_64-linux-gnu. That means that including the <stdatomic.h>
header in C++23, or switching from C++20 to C++23 when already including <stdatomic.h>
, changes the ABI for the type that is spelled _Atomic(A)
.
In some sense this is the same issue as #26836, but we're now seeing different ABI behavior with two Clang builds depending on a -std=
flag / a #include
, which seems worse than before.