diff --git a/man/manual.docbook b/man/manual.docbook index 820d4b3c4..fe6580655 100644 --- a/man/manual.docbook +++ b/man/manual.docbook @@ -592,55 +592,6 @@ void DestroyFred(void *p) - - Exception safety - - Cppcheck has a few checks that ensure that you don't break the basic - guarantee of exception safety. It doesn't have any checks for the strong - guarantee yet. - - Example: - - Fred::Fred() : a(new int[20]), b(new int[20]) -{ -} - - By default Cppcheck will not detect any problems in that - code. - - To enable the exception safety checking you can use - --enable: - - cppcheck --enable=exceptNew --enable=exceptRealloc fred.cpp - - The output will be: - - [fred.cpp:3]: (style) Upon exception there is memory leak: a - - If an exception occurs when b is allocated, - a will leak. - - Here is another example: - - int *p; - -int a(int sz) -{ - delete [] p; - if (sz <= 0) - throw std::runtime_error("size <= 0"); - p = new int[sz]; -} - - Check that with Cppcheck: - - cppcheck --enable=exceptNew --enable=exceptRealloc except2.cpp - - The output from Cppcheck is: - - [except2.cpp:7]: (error) Throwing exception in invalid state, p points at deallocated memory - - HTML report