https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118854
--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> --- https://en.cppreference.com/w/cpp/memory/shared_ptr is explicit about it (emphasis mine): All member functions (including copy constructor and copy assignment) can be called by multiple threads on different shared_ptr objects without additional synchronization even if these objects are copies and share ownership of the same object. If multiple threads of execution access the same shared_ptr object without synchronization and ***any of those accesses uses a non-const member function of shared_ptr then a data race will occur***; the std::atomic<shared_ptr> can be used to prevent the data race.