What happens when a destructor throws (sandordargo.com)
The post explains what happens in C++ when a destructor throws, noting that destructors are implicitly treated as noexcept(true) since C++11. If a destructor throws without another exception already in flight, the program calls std::terminate unless the destructor is explicitly declared noexcept(false), in which case the exception can propagate and be caught. However, if a destructor throws during stack unwinding (when another exception is active), std::terminate is called and the program cannot recover. The author concludes that throwing from destructors is generally unsafe and recommends logging or recording errors instead.
April 07, 2026 02:26
Source: Hacker News