[libcxx-commits] [libcxx] [libcxx] Implementation of non lock-free atomic shared_ptr (PR #194215)

Vladislav Semykin via libcxx-commits libcxx-commits at lists.llvm.org
Sun Apr 26 11:25:07 PDT 2026


ViNN280801 wrote:

Is a lock-free implementation strictly required, or is a conforming lock-based implementation acceptable as a first step?

The standard does not mandate lock-free - `is_always_lock_free == false` is explicitly permitted. Both libstdc++ (GCC 12) and MSVC STL ship lock-based implementations today. I understand that libc++ aims for higher quality, but a portable lock-free path requires either DWCAS (16-byte CAS, available on x86-64 cx16 and AArch64 LSE) or hazard pointers (P2530R3, targeted for C++26) - neither is trivially portable across all supported platforms today.

This PR is intended as Phase 1: correct, standard-conforming, lock-based. A lock-free follow-up can come once the prerequisite infrastructure is in place.

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


More information about the libcxx-commits mailing list