On Fri, 4 Aug 2023, 10:07 Jonathan Wakely, <jwakely.gcc@xxxxxxxxx> wrote: > > > On Thu, 3 Aug 2023, 14:35 Bogdan Sinitsyn, <f1u77y@xxxxxxxxx> wrote: > >> std::atomic<std::shared_ptr<T>> operations seem to generate lock-free >> code without _Sp_locker and mutexes, while >> std::atomic_*(std::shared_ptr<T>*) operations use _Sp_locker. But >> std::atomic_is_lock_free and std::atomic::is_lock_free >> show exactly the opposite. > > > Not always. > > atomic<shared_ptr<T>>::is_lock_free is always true, which is correct. > Or did I make it always false? I don't remember now. But it's always the same and doesn't depend on linking to libpthread. The lock free property doesn't mean no mutex is used, it's about forward progress guarantees and blocking, not about the explicit presence of a mutex. > atomic_is_lock_free(shared_ptr<T>*) is true in a single threaded program, > false otherwise. If the program is not linked to libpthread then no locking > is used (or needed) for the atomic_xxx(shared_ptr*,...) overloads. > > > > > > Maybe I don't interpret that correctly? What >> does that supposed to mean? >> >> https://godbolt.org/z/818v6sMGb >> >> -- >> >> Bogdan Sinisyn >> >>