The destructor of the the C++11 std::exception
base class is not noexcept
, and thus may (in theory) throw an exception, which consequent relaxed permission for all its derived classes (including std::bad_alloc
and std::runtime_error
). The destructor of the C++98 std::exception
however had a throw()
exception specification, indicating it was not permitted to throw exceptions. Why the difference? Why is it now permitted to throw exceptions? The permission is particularly odd given that the std::exception
constructors are now noexcept
: you can safely construct such an object, but you can not safely destroy it: the opposite of the normal behaviour.
Having the destructor of an exception class throw an exception is usually disastrous. What can cause std::exception::~exception
to throw an exception?