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
24
u/n1ghtyunso Apr 02 '26
for function try blocks, the catch seems to be considered outside of the function body, which in case of destructors causes this behaviour.
Moving the try block into the destructor body makes it work as excepted.
That's a rather minute detail huh.