http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51798
--- Comment #27 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-09
09:16:11 UTC ---
Nice. Now that we have an atomic load we can also do:
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -193,7 +193,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
// No memory barrier is used here so there is no synchronization
// with other threads.
- return const_cast<const volatile _Atomic_word&>(_M_use_count);
+ return __atomic_load_n(&_M_use_count, __ATOMIC_RELAXED);
}
private: