r/cpp • u/pavel_v • Apr 02 '26
What happens when a destructor throws
https://www.sandordargo.com/blog/2026/04/01/when-a-destructor-throws
102
Upvotes
r/cpp • u/pavel_v • Apr 02 '26
View all comments
Show parent comment
6
u/kpt_ageus Apr 02 '26
By default exceptions can't be caught because of noexcept(true). Your program is terminated and you can't do anything about it. If you set noexcept to false, you can catch it and recover. But if another exception is thrown while stack is unwinded, your program is terminated again.
So basically every exception thrown in destructor is potential std::terminate