[libcxx-commits] [libcxx] [libc++] Add a test for the ABI of std::once_flag (PR #218924)

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 27 04:45:57 PDT 2026


mstorsjo wrote:

> @mstorsjo it looks like MinGW is the only platform where `sizeof(std::once_flag) != sizeof(void*)`. Do you think this should be changed, like it has been for MSVC?

Hmm, tricky. So I see that the culprit is at https://github.com/llvm/llvm-project/blob/llvmorg-23.1.0/libcxx/include/__mutex/once_flag.h#L55-L59, originating in https://github.com/llvm/llvm-project/commit/0fd00a581d929c3caa2e92fbd06cdc1ae88fa457. The ifdef clearly should be for windows in general, not specifically for the MSVC style ABIs.

(If fixing it, I presume we should fix both `__mutex/once_flag.h` and `__cxx03/__mutex/once_flag.h`, to keep the ABI in sync for people using it in C++03 mode as well.)

Fixing it will be an ABI break for any code that uses `std::once_flag` - which isn't great, but the current state of the implicit ABI here also seems unintentional.

What do @lazka and @mati865 think about that for this case? Do you happen to have a ballpark number of how many msys2 packages would be affected by an ABI break around `std::once_flag`, i.e. any package calling `std::call_once` with a dynamically linked lbc++?

https://github.com/llvm/llvm-project/pull/218924


More information about the libcxx-commits mailing list