https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86583
Bug ID: 86583 Summary: exception specification of explicitly defaulted destructor does not match the calculated one Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zhonghao at pku dot org.cn Target Milestone: --- The code is as follow: struct T { T() noexcept(false) { } ~T() noexcept(false) { } }; struct A { A() noexcept = default; ~A() noexcept = default; T t; }; g++ accepts the code, but I think it shouldn't be. In fact, g++4.9.0 rejects the code: ex.cc:8:5: error: function 'A::A()' defaulted on its first declaration with an exception-specification that differs from the implicit declaration 'A::A()' A() noexcept = default; ^ ex.cc:9:5: error: function 'A::~A()' defaulted on its first declaration with an exception-specification that differs from the implicit declaration 'A::~A()' ~A() noexcept = default; I tried clang++. It also rejects the code: ex.cc:8:2: error: exception specification of explicitly defaulted default constructor does not match the calculated one A() noexcept = default; ^ ex.cc:9:2: error: exception specification of explicitly defaulted destructor does not match the calculated one ~A() noexcept = default; ^ 2 errors generated.