[Development] Error "invokes deleted constructor" while building Qt5 with clang and libc++
Thiago Macieira
thiago.macieira at intel.com
Mon Dec 3 20:42:06 CET 2012
On segunda-feira, 3 de dezembro de 2012 15.37.13, Francisco Lopes wrote:
> Please take a look at my last comment on the bug report (
> http://llvm.org/bugs/show_bug.cgi?id=14486#c10). If my analysis is right,
> it's wrong to use "= {0}" with an inaccessible copy constructor.
Looking at N3337, this is the API required for std::atomic:
atomic() noexcept = default;
constexpr atomic(T) noexcept;
atomic(const atomic&) = delete;
atomic& operator=(const atomic&) = delete;
atomic& operator=(const atomic&) volatile = delete;
T operator=(T) volatile noexcept;
T operator=(T) noexcept;
It also defines ATOMIC_VAR_INIT and in 29.6.5 [atomics.types.operations.req]
paragraph 6 we find this example:
atomic<int> v = ATOMIC_VAR_INIT(5);
The standard does not define what ATOMIC_VAR_INIT is. GCC defines it as:
#define ATOMIC_VAR_INIT(_VI) { _VI }
And clang defines it (see [1]) as:
#define ATOMIC_VAR_INIT(__v) {__v}
With constructors:
_LIBCPP_INLINE_VISIBILITY
atomic() _NOEXCEPT {} // = default;
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
_LIBCPP_INLINE_VISIBILITY
_Tp operator=(_Tp __d) volatile _NOEXCEPT
{__base::store(__d); return __d;}
_LIBCPP_INLINE_VISIBILITY
_Tp operator=(_Tp __d) _NOEXCEPT
{__base::store(__d); return __d;}
inheriting:
__atomic_base(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) volatile = delete;
In other words, libc++'s own std::atomic is supposed to be initialised by
braces with a deleted copy constructor and assignment operator. It seems to me
that it's a compiler bug.
[1] http://llvm.org/svn/llvm-project/libcxx/trunk/include/atomic
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20121203/c5ec18d6/attachment.sig>
More information about the Development
mailing list