News for hackers. Stuff that matters.
Re:Misra C++:2023 Published by GrumpySloth on Monday December 18, 2023 @02:11PM (#38686826)
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.
Re:Misra C++:2023 Published by jstimpfle on Monday December 18, 2023 @07:52PM (#38690447)
Again, you need to make the constructor exception safe, that's just like any other function. Just imagine the constructor and destructor bodies as one combined function. (Of course don't forget the method calls in between but those should preserve the class invariant).