https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69301
Bug ID: 69301 Summary: std::atomic<T>::load() won't compile if T doesn't have a default constructor Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: anthony.ajw at gmail dot com Target Milestone: --- Created attachment 37360 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37360&action=edit atomic_no_default_constructor.cpp The attached simple code fails to compile with g++ 5.3 in C++1y mode because NoDefaultConstructor doesn't have a default constructor. The error message is quoted below. g++-5 -std=c++1y atomic_no_default_constructor.cpp In file included from atomic_no_default_constructor.cpp:1:0: /usr/include/c++/5/atomic: In instantiation of ‘_Tp std::atomic<_Tp>::load(std::memory_order) const [with _Tp = NoDefaultConstructor; std::memory_order = std::memory_order]’: atomic_no_default_constructor.cpp:11:12: required from here /usr/include/c++/5/atomic:234:13: error: no matching function for call to ‘NoDefaultConstructor::NoDefaultConstructor()’ _Tp tmp; ^ atomic_no_default_constructor.cpp:5:15: note: candidate: constexpr NoDefaultConstructor::NoDefaultConstructor(int) constexpr NoDefaultConstructor(int i_) noexcept : i(i_) {} ^ atomic_no_default_constructor.cpp:5:15: note: candidate expects 1 argument, 0 provided atomic_no_default_constructor.cpp:3:8: note: candidate: constexpr NoDefaultConstructor::NoDefaultConstructor(const NoDefaultConstructor&) struct NoDefaultConstructor{ ^ atomic_no_default_constructor.cpp:3:8: note: candidate expects 1 argument, 0 provided atomic_no_default_constructor.cpp:3:8: note: candidate: constexpr NoDefaultConstructor::NoDefaultConstructor(NoDefaultConstructor&&) atomic_no_default_constructor.cpp:3:8: note: candidate expects 1 argument, 0 provided