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
1
u/The_JSQuareD Apr 03 '26
It's a destructor, so no. And in most cases there wouldn't even be a way to refer to the object anymore since it went out of scope.
I think you could just say the object's state is unspecified, and any code whose behavior depends on the state of the object at that point invokes UB. I believe in most cases relying on an object's state after the destructor has run would be UB anyway (so in the case with no exceptions).