[Bug c++/67036] GCC does not warn of throwing destructors in C++11, even when they lack noexcept(false) and std::uncaught_exception

egallager at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Sep 28 12:16:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67036

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
I get a warning from -Wterminate with current gcc:

$ /usr/local/bin/g++ -O1 -Wall -Wextra -c -pedantic 67036.cc
67036.cc: In destructor ‘useless::~useless()’:
67036.cc:7:90: warning: throw will always call terminate() [-Wterminate]
     ~useless() { std::cout << "out" << std::endl; throw
std::runtime_error("who knows..."); }
                                                                               
          ^
67036.cc:7:90: note: in C++11 destructors default to noexcept
67036.cc: In function ‘int main(int, char**)’:
67036.cc:10:31: warning: unused parameter ‘argv’ [-Wunused-parameter]
 int main(int argc, char* argv[])
                               ^
$

Is this what you were looking for?


More information about the Gcc-bugs mailing list