Why is it generally considered a bad practice to throw an exception from a destructor? What happens if an exception is thrown during stack unwinding?

Last updated 21 June 2026

  • Destructors run during stack unwinding. If one throws while another exception is already propagating, C++ can't handle two at once and calls std::terminate().

  • Since C++11 destructors are implicitly noexcept, so any escaping exception terminates the program even outside unwinding.

  • Instead, catch and log errors inside the destructor, and offer a separate throwing close()/commit() method for reporting failures.

  • https://isocpp.org/blog/2026/05/what-happens-when-a-destructor-throws-sandor-dargo
  • https://isocpp.org/wiki/faq/exceptions
All C++ interview questions