http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59526
Bug ID: 59526 Summary: [C++11] Defaulted special member functions don't accept noexcept if a member has a non-trivial noexcept operator in the corresponding special member function Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: bootsarehax at gmail dot com The following code fails for struct X on gcc 4.8.2 with: bla.cpp:15:3: error: function ‘X::X()’ defaulted on its first declaration with an exception-specification that differs from the implicit declaration ‘X::X()’ X() noexcept = default; bla.cpp:16:6: error: function ‘X& X::operator=(X&&)’ defaulted on its first declaration with an exception-specification that differs from the implicit declaration ‘X& X::operator=(X&&)’ X& operator=(X&&) noexcept = default; #include <type_traits> template<bool b> struct F { F() noexcept(b) {} F& operator=(F&&) noexcept(b) {return *this;} }; struct Simple { Simple() noexcept {} Simple& operator=(Simple&&) noexcept {return *this;} }; struct X { X() noexcept = default; X& operator=(X&&) noexcept = default; F<true> f; }; struct X2 { X2() /* noexcept */ = default; X2& operator=(X2&&) /* noexcept */ = default; F<true> f; }; struct X3 { X3() noexcept = default; X3& operator=(X3&&) noexcept = default; Simple f; }; static_assert(std::is_nothrow_constructible<X>::value, ""); static_assert(std::is_nothrow_move_assignable<X>::value, ""); static_assert(std::is_nothrow_constructible<X2>::value, ""); static_assert(std::is_nothrow_move_assignable<X2>::value, ""); static_assert(std::is_nothrow_constructible<X3>::value, ""); static_assert(std::is_nothrow_move_assignable<X3>::value, ""); X2 shows that a noexcept function is implicitly generated. X3 shows that it is necessary for the noexcept operator to depend on a template parameter to trigger this behavior.