Index: libcxx/include/atomic =================================================================== --- libcxx/include/atomic +++ libcxx/include/atomic @@ -1685,16 +1685,10 @@ #ifndef _LIBCPP_CXX03_LANG __atomic_base(const __atomic_base&) = delete; - __atomic_base& operator=(const __atomic_base&) = delete; - __atomic_base& operator=(const __atomic_base&) volatile = delete; #else private: _LIBCPP_INLINE_VISIBILITY __atomic_base(const __atomic_base&); - _LIBCPP_INLINE_VISIBILITY - __atomic_base& operator=(const __atomic_base&); - _LIBCPP_INLINE_VISIBILITY - __atomic_base& operator=(const __atomic_base&) volatile; #endif }; @@ -1804,6 +1798,18 @@ _LIBCPP_INLINE_VISIBILITY _Tp operator=(_Tp __d) _NOEXCEPT {__base::store(__d); return __d;} + + // delete explicitly in the most derived class to fix the Bug 41784 +#ifndef _LIBCPP_CXX03_LANG + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; +#else +private: + _LIBCPP_INLINE_VISIBILITY + atomic& operator=(const atomic&); + _LIBCPP_INLINE_VISIBILITY + atomic& operator=(const atomic&) volatile; +#endif }; // atomic @@ -1866,6 +1872,18 @@ _Tp* operator-=(ptrdiff_t __op) volatile _NOEXCEPT {return fetch_sub(__op) - __op;} _LIBCPP_INLINE_VISIBILITY _Tp* operator-=(ptrdiff_t __op) _NOEXCEPT {return fetch_sub(__op) - __op;} + + // delete explicitly in the most derived class to fix the Bug 41784 +#ifndef _LIBCPP_CXX03_LANG + atomic& operator=(const atomic&) = delete; + atomic& operator=(const atomic&) volatile = delete; +#else +private: + _LIBCPP_INLINE_VISIBILITY + atomic& operator=(const atomic&); + _LIBCPP_INLINE_VISIBILITY + atomic& operator=(const atomic&) volatile; +#endif }; // atomic_is_lock_free Index: libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.ptr.volatile.fail.cpp =================================================================== --- /dev/null +++ libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.ptr.volatile.fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// std::atomic + +// atomic& operator=( const atomic& ) volatile = delete; + +#include + +int +main() +{ + volatile std::atomic obj1; + std::atomic obj2; + obj1 = obj2; // expected-error {{overload resolution selected deleted operator '='}} +} Index: libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.volatile.fail.cpp =================================================================== --- /dev/null +++ libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/copy.assign.volatile.fail.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// std::atomic + +// atomic& operator=( const atomic& ) volatile = delete; + +#include + +int +main() +{ + volatile std::atomic obj1; + std::atomic obj2; + obj1 = obj2; // expected-error {{overload resolution selected deleted operator '='}} +}