https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81632
Bug ID: 81632 Summary: spurious -Wterminate warning about throw in destructor Product: gcc Version: 7.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: akim.demaille at gmail dot com Target Milestone: --- In the following piece of code GCC issues a spurious warning about an exception that escapes a dtor, although it is actually caught. Observed with GCC 6 and 7. GCC 5 does not feature -Wterminate. $ cat /tmp/foo.cc struct foo { ~foo() { try { throw 42; } catch (int) { throw; } catch (...) { } } }; int main() { } $ g++-mp-6 --version g++-mp-6 (MacPorts gcc6 6.3.0_2) 6.3.0 Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++-mp-6 -Wterminate /tmp/foo.cc -std=c++14 /tmp/foo.cc: In destructor 'foo::~foo()': /tmp/foo.cc:11:9: warning: throw will always call terminate() [-Wterminate] throw; ^~~~~ /tmp/foo.cc:11:9: note: in C++11 destructors default to noexcept $ g++-mp-7 --version g++-mp-7 (MacPorts gcc7 7-20170622_0) 7.1. Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++-mp-7 -Wterminate /tmp/foo.cc -std=c++14 /tmp/foo.cc: In destructor 'foo::~foo()': /tmp/foo.cc:11:9: warning: throw will always call terminate() [-Wterminate] throw; ^~~~~ /tmp/foo.cc:11:9: note: in C++11 destructors default to noexcept There is no such warning if this try/catch is wrapped in another one, so that's really just the logic of bouncing to another catch clause that is missing. Cheers!