Stephan Tolksdorf: fixes the issue in the <atomic> header and adds corresponding tests. I've used macros to fall back to a user-provided default constructor if _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS (though I suspect that there won't be many users defining that macro).
The tests use placement new to check that atomic values get properly zero-initialized. I had to modify the atomic_is_lock_free test, because default initialization of an object of const type 'const A' (aka 'const atomic<int>') requires a user-provided default constructor. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@180945 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -622,7 +622,12 @@ struct __atomic_base // false
|
||||
{return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__atomic_base() _NOEXCEPT {} // = default;
|
||||
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
__atomic_base() _NOEXCEPT = default;
|
||||
#else
|
||||
__atomic_base() _NOEXCEPT : __a_() {}
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
|
||||
#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS
|
||||
@@ -645,7 +650,7 @@ struct __atomic_base<_Tp, true>
|
||||
{
|
||||
typedef __atomic_base<_Tp, false> __base;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
__atomic_base() _NOEXCEPT {} // = default;
|
||||
__atomic_base() _NOEXCEPT _LIBCPP_DEFAULT
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
|
||||
|
||||
@@ -726,7 +731,7 @@ struct atomic
|
||||
{
|
||||
typedef __atomic_base<_Tp> __base;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
atomic() _NOEXCEPT {} // = default;
|
||||
atomic() _NOEXCEPT _LIBCPP_DEFAULT
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
|
||||
|
||||
@@ -746,7 +751,7 @@ struct atomic<_Tp*>
|
||||
{
|
||||
typedef __atomic_base<_Tp*> __base;
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
atomic() _NOEXCEPT {} // = default;
|
||||
atomic() _NOEXCEPT _LIBCPP_DEFAULT
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
_LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {}
|
||||
|
||||
@@ -1367,7 +1372,12 @@ typedef struct atomic_flag
|
||||
{__c11_atomic_store(&__a_, false, __m);}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
atomic_flag() _NOEXCEPT {} // = default;
|
||||
#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
atomic_flag() _NOEXCEPT = default;
|
||||
#else
|
||||
atomic_flag() _NOEXCEPT : __a_() {}
|
||||
#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user