From 7e61d1f2da6376b88aff34e5da2b453d58df3577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 11 Jan 2013 16:55:00 +0100 Subject: [PATCH] manual: Removed chapter about exception safety checks. They are enabled by the normal --enable=all. --- man/manual.docbook | 49 ---------------------------------------------- 1 file changed, 49 deletions(-) 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