Both the last released version 8.7 and the current master branch (2038ab1) have an incorrect order of the release fence and pointer store operations when creating the object.
The current current code is
T *newObject = m_objectFactory();
s_pObject.store(newObject, std::memory_order_relaxed);
std::atomic_thread_fence(std::memory_order_release);
however the correct sequence, which is also described in the article linked from the function documentation, should be
T *newObject = m_objectFactory();
std::atomic_thread_fence(std::memory_order_release);
s_pObject.store(newObject, std::memory_order_relaxed);
Otherwise there is no guarantee that the object content will be already fully stored in the memory when another thread might see the pointer and attempt to access it.
Both the last released version 8.7 and the current master branch (2038ab1) have an incorrect order of the release fence and pointer store operations when creating the object.
The current current code is
however the correct sequence, which is also described in the article linked from the function documentation, should be
Otherwise there is no guarantee that the object content will be already fully stored in the memory when another thread might see the pointer and attempt to access it.