[LLVMbugs] [Bug 18097] New: atomic<> of trivially copyable class is rejected

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Nov 30 01:15:11 PST 2013


            Bug ID: 18097
           Summary: atomic<> of trivially copyable class is rejected
           Product: libc++
           Version: 3.2
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: hhinnant at apple.com
          Reporter: tim at klingt.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

the following code does not compile (taken from

#include <atomic>
#include <type_traits>

struct A
    int i_;                                                                     

    A(int i) : i_(i) {}                                                         

static_assert(std::is_trivially_copyable<A>::value, "");                        

    std::atomic<A> q(A(1));                                                     

/usr/include/c++/v1/atomic:632:58: error: no viable conversion from 'A' to
    _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
                                                         ^    ~~~
/usr/include/c++/v1/atomic:736:51: note: in instantiation of member function
'std::__1::__atomic_base<A, false>::__atomic_base' requested here
    _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}
x.cpp:16:20: note: in instantiation of member function
'std::__1::atomic<A>::atomic' requested here
    std::atomic<A> q(A(1));

this is a showstopper for compiling boost.lockfree with std::atomic on clang.

more discussions on this issue:

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131130/9ca487c8/attachment.html>

More information about the llvm-bugs mailing list