https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118854
--- Comment #18 from Nicholas Williams <nicholas at nicholaswilliams dot net> --- (In reply to Jonathan Wakely from comment #17) > > You must stop accessing a global object while it's being destroyed in > another thread. I really don't know why this needs to be repeated so many > times. Well in this case, at least, it had to be repeated because of *your* previous and now-allegedly-incorrect statement that I could use atomic<shared_ptr> to work around this problem: > If you need to make copies of a shared_ptr while also modifying it, you need > to use std::atomic<std::shared_ptr<T>> As for this: > N.B. std::atomic::~atomic() is not an atomic operation For my reading, could you link to this? I cannot find any documentation that specifies one way or another whether ~atomic is atomic. For that matter, neither the documentation for std::atomic<T> nor the documentation for the specialization std::atomic<std::shared_ptr<T>> indicate that a destructor even exists.