http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58605
Bug ID: 58605
Summary: atomic<T>::atomic() disobeys
[atomics.types.operations.req]p4 for types with
user-defined default constructors
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: jyasskin at gcc dot gnu.org
[atomics.types.operations.req]p4 says:
A::A() noexcept = default;
Effects: leaves the atomic object in an uninitialized state. [ Note: These
semantics ensure compatibility
with C. — end note ]
http://gcc.gnu.org/viewcvs/gcc/trunk/libstdc%2B%2B-v3/include/std/atomic?revision=201315&view=markup#l160
includes:
template<typename _Tp>
struct atomic
{
private:
_Tp _M_i;
If _Tp has a non-trivial default constructor, this will cause atomic<_Tp>'s
default constructor to initialize the member. Using a bare member also adds
requirements on the signature of _Tp::_Tp(), in particular that it must now be
noexcept.
libc++ handles this by defining a "mutable _Atomic(_Tp)" member instead:
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/atomic?revision=180945&view=markup#l558