[cfe-dev] Non Static Member Initialization and deleted copy constructor
Howard Hinnant
hhinnant at apple.com
Thu Jul 26 12:30:37 PDT 2012
This looks wrong to me. Is this a known bug?
#include <atomic>
//
// This class can compile
//
class Working
{
private:
std::atomic<int> value_{0};
};
//
// This class cannot compile
//
template <typename Ty1>
class NotWorking
{
private:
std::atomic<int> value_{0}; // <---- error here
};
int main()
{
Working working;
NotWorking<int> not_working;
}
test.cpp:19:33: error: copying member subobject of type 'std::atomic<int>' invokes deleted constructor
std::atomic<int> value_{0}; // <---- error here
^
test.cpp:25:21: note: in instantiation of template class 'NotWorking<int>' requested here
NotWorking<int> not_working;
^
/Users/hhinnant/Development/temp_libcxx/include/atomic:721:7: note: copy constructor of 'atomic<int>' is implicitly deleted because base class
'__atomic_base<int>' has a deleted copy constructor
: public __atomic_base<_Tp>
^
/Users/hhinnant/Development/temp_libcxx/include/atomic:640:7: note: copy constructor of '__atomic_base<int, true>' is implicitly deleted because base class
'__atomic_base<int, false>' has a deleted copy constructor
: public __atomic_base<_Tp, false>
^
/Users/hhinnant/Development/temp_libcxx/include/atomic:625:5: note: function has been explicitly marked deleted here
__atomic_base(const __atomic_base&) = delete;
^
1 error generated.
Thanks,
Howard
More information about the cfe-dev
mailing list