List of potential checkers
- +allocation/deallocation
memory.NegativeArraySize
enhancement to experimental.security.MallocOverflow (C, C++) -‘n’ is used to specify the buffer size may be negative +'n' is used to specify the buffer size may be negative | #include <stdlib.h> @@ -189,7 +189,7 @@ void test() { |
constructors/destructors
exceptions
smart pointers
undefined behavior
@@ -485,7 +485,7 @@ void test() { *iq = 1; // warn const Y y; - Y* p = const_cast<Y*>(&y); + Y* p = const_cast<Y*>(&y); p->x.i = 1; // ok p->x.j = 1; // warn } @@ -544,10 +544,10 @@ struct non_POD : public POD { extern POD pod; extern non_POD non_pod; -int *p1 = &non_pod.j; // warn -int *p2 = &non_pod.pod.i; // warn -int *p3 = &pod.i; // ok -POD *p4 = & non_pod; // warn +int *p1 = &non_pod.j; // warn +int *p2 = &non_pod.pod.i; // warn +int *p3 = &pod.i; // ok +POD *p4 = &non_pod; // warn POD a; non_POD b; @@ -555,7 +555,7 @@ non_POD b; struct S { int *k; non_POD non_pod; - S() : k(&non_pod.j) {} // warn + S() : k(&non_pod.j) {} // warn }; // C++11 @@ -572,10 +572,10 @@ struct non_trivial: public trivial { extern trivial t; extern non_trivial nt; -int *p1 = &nt.j; // warn -int *p2 = &nt.i; // warn -int *p3 = &t.i; // ok -trivial *p4 = &nt; +int *p1 = &nt.j; // warn +int *p2 = &nt.i; // warn +int *p3 = &t.i; // ok +trivial *p4 = &nt; trivial t; non_trivial nt; @@ -583,7 +583,7 @@ non_trivial nt; struct S { int *k; non_trivial nt; - S() : k(&nt.j) {} // warn + S() : k(&nt.j) {} // warn }; | @@ -820,12 +820,12 @@ The effects are undefined if an exception is thrown. | struct S { int i, j; - S (const S &s) { + S (const S &s) { i = s.i; throw 1; // warn j = s.j; }; - S& operator=(const S &s) { + S &operator=(const S &s) { i = s.i; throw 1; // warn j = s.j; @@ -993,8 +993,8 @@ class my_streambuf : public std::streambuf { void test() { std::filebuf fb; - std::istream in(&fb); - std::ostream out(&fb); + std::istream in(&fb); + std::ostream out(&fb); std::filebuf::off_type pos(-1); in.seekg(pos); // warn out.seekp(-1); // warn @@ -1002,7 +1002,7 @@ void test() { |
different
different.WrongVarForStmt
(C, C++) -Possibly wrong variable is used in the loop/cond-expression of the ‘for’ -statement. Did you mean ‘proper_variable_name’? +Possibly wrong variable is used in the loop/cond-expression of the 'for' +statement. Did you mean 'proper_variable_name'? | void test() { int i; @@ -1213,21 +1213,21 @@ void test() { |
WinAPI
@@ -1548,7 +1548,7 @@ void test() |
optimization
optimization.EmptyCstrDetect
(C) -Optimization: it is more efficient to use “str[0] != ‘\0’” to identify an empty +Optimization: it is more efficient to use "str[0] != '\0'" to identify an empty string | #include <string.h> |