Re:Misra C++:2023 Published
by mgaunard on Monday December 18, 2023 @10:07AM
(#38683439)
The problem you mention doesn't exist, since destructors are not called when a constructor throws.
[ Parent
| on HN ]
Re:Misra C++:2023 Published
by GrumpySloth on Monday December 18, 2023 @02:12PM
(#38686835)
If you call mmap/VirtualAlloc/open/fopen in your constructor and later it throws, you will have a resource leak, because the destructor won’t clean it up.
If you don't know how to write exception-safe code -- for which RAII is the most common idiom -- then you have exception safety issues.
I don't see how that relates to the thread, other than to say exceptions in constructors are quite fundamental.