What happens if an exception is thrown inside a constructor or a destructor?

Last updated 21 June 2026

  • Constructor throw is safe: the object never exists, so its destructor is NOT called, but already-constructed members and bases are destroyed in reverse order.

  • Resources acquired raw in a constructor body leak on throw. Wrap each in an RAII member (e.g. std::unique_ptr) so it cleans itself up.

  • Destructor throw is dangerous: destructors are implicitly noexcept, so an escaping exception (or a second one during unwinding) calls std::terminate().

  • https://learn.microsoft.com/en-us/cpp/cpp/how-to-design-for-exception-safety?view=msvc-170
  • https://learn.microsoft.com/en-us/cpp/code-quality/c6278?view=msvc-170
All C++ interview questions