April 6, 2026
When cleanup code goes nuclear
What happens when a destructor throws
Dev interview question sparks a flame war: trivia test or trash talk
TLDR: A C++ blogger used a gotcha interview question about error-throwing cleanup functions, showing they can crash programs unless explicitly allowed and even then are risky. The comments lit up: critics slammed gatekeeping trivia, others joked back, and a few admitted they learned something—fueling a wider fight over interview culture
A C++ blogger re-lit an age-old landmine: what happens when a destructor — the tiny cleanup function that runs when an object goes away — throws an error? He uses it as an interview test, claims many seniors can’t explain it, and then demos that since 2011 most destructors are “no-throw” by default. If they do throw, programs can instantly quit; unless you mark it noexcept(false), and even then throwing during another error can still blow everything up. The code receipts are here example. Translation: throw in cleanup, and your app can nuke itself. But the community didn’t debate the code — they exploded over the vibe.
The top reactions split into three camps. The gatekeepers joked about “vtables and thunks” and mock-rejected the author with “we decided to proceed with another candidate.” The pragmatists dragged the question as trivia that “doesn’t matter at senior level” and called the piece “a junior engineer’s idea of senior.” And the learners confessed they never knew destructors could legally throw at all. Result: a bonfire of interview culture wars, with memes, eye-rolls, and a side of real education. Tech takeaway? Don’t make your cleanup code throw. Social takeaway? Don’t make your interviews do the same
Key Points
- •Destructors are central to RAII, ensuring resources are released even when control flow changes.
- •Since C++11, destructors are implicitly noexcept(true) unless declared otherwise or a base/member destructor can throw.
- •If a destructor marked as noexcept(true) throws, std::terminate is called because the noexcept guarantee is violated.
- •If a destructor is explicitly marked noexcept(false) and no other exception is active, its exception can propagate and be caught.
- •If a destructor throws during stack unwinding (another exception is active), std::terminate is called.