<div id="content">
<h1>List of potential checkers</h1>
-<!---------------------------- allocation/deallocation -------------------------->
+<!-- ========================= allocation/deallocation ======================= -->
<h3>allocation/deallocation</h3>
<table class="checkers">
<col class="namedescr"><col class="example"><col class="progress">
<tr><td><span class="name">memory.NegativeArraySize
<br>enhancement to experimental.security.MallocOverflow<br>(C, C++)
</span><br><br>
-\91n\92 is used to specify the buffer size may be negative
+'n' is used to specify the buffer size may be negative
</td><td><pre>
#include <stdlib.h>
</table>
-<!-------------------------- constructors/destructors ------------------------->
+<!-- ======================= constructors/destructors ====================== -->
<h3>constructors/destructors</h3>
<table class="checkers">
<col class="namedescr"><col class="example"><col class="progress">
</table>
-<!--------------------------------- exceptions -------------------------------->
+<!-- ============================== exceptions ============================= -->
<h3>exceptions</h3>
<table class="checkers">
<col class="namedescr"><col class="example"><col class="progress">
</table>
-<!---------------------------- smart pointers --------------------------------->
+<!-- ========================= smart pointers ============================== -->
<h3>smart pointers</h3>
<table class="checkers">
<col class="namedescr"><col class="example"><col class="progress">
</table>
-<!---------------------------- undefined behavior ----------------------------->
+<!-- ========================= undefined behavior ========================== -->
<h3>undefined behavior</h3>
<table class="checkers">
<col class="namedescr"><col class="example"><col class="progress">
B *b1 = new B;
B b2;
new (b1) T;
- new (&b2) T;
+ new (&b2) T;
delete b1; // warn
} // warn
</pre></td><td></td></tr>
*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
}
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;
struct S {
int *k;
non_POD non_pod;
- S() : k(&non_pod.j) {} // warn
+ S() : k(&non_pod.j) {} // warn
};
// C++11
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;
struct S {
int *k;
non_trivial nt;
- S() : k(&nt.j) {} // warn
+ S() : k(&nt.j) {} // warn
};
</pre></td><td></td></tr>
</td><td><pre>
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;
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
</pre></td><td></td></tr>
</table>
-<!------------------------------- different ----------------------------------->
+<!-- ============================ different ================================ -->
<h3>different</h3>
<table class="checkers">
<col class="namedescr"><col class="example"><col class="progress">
<tr><td><span class="name">different.WrongVarForStmt
<br>(C, C++)</span><br><br>
-Possibly wrong variable is used in the loop/cond-expression of the \91for\92
-statement. Did you mean \91proper_variable_name\92?
+Possibly wrong variable is used in the loop/cond-expression of the 'for'
+statement. Did you mean 'proper_variable_name'?
</td><td><pre>
void test() {
int i;
<tr><td><span class="name">different.BitwiseOpBoolArg
<br>maybe join with experimental.core.BoolAssignment<br>(C, C++)</span><br><br>
-bool value is used at the left/right part of the & (|) operator. Did you mean
-&& (||) ?
+bool value is used at the left/right part of the & (|) operator. Did you mean
+&& (||) ?
</td><td><pre>
int f();
void test() {
bool b = true;
- if (b & f()) {} // warn
+ if (b & f()) {} // warn
}
</pre></td><td></td></tr>
<tr><td><span class="name">different.LabelInsideSwitch
<br>(C)</span><br><br>
Possible misprint: label found inside the switch() statement. (* did you mean
-\91default\92?)
+'default'?)
</td><td><pre>
void test() {
int c = 7;
<tr><td><span class="name">different.IdenticalCondIfIf
<br>(C)</span><br><br>
-The conditions of two subsequent \91if\92 statements are identical
+The conditions of two subsequent 'if' statements are identical
</td><td><pre>
void test() {
int c = 7;
<tr><td><span class="name">different.CondOpIdenticalReturn
<br>(C)</span><br><br>
-The return expressions of the \91?:\92 operator are identical
+The return expressions of the '?:' operator are identical
</td><td><pre>
void test() {
unsigned a;
<tr><td><span class="name">different.UnaryPlusWithUnsigned
<br>(C)</span><br><br>
-Using \91unary +\92 with unsigned is meaningless
+Using 'unary +' with unsigned is meaningless
</td><td><pre>
void test() {
unsigned a;
<tr><td><span class="name">different.LogicalOpUselessArg
<br>(C)</span><br><br>
-The second operand of the && operator has no impact on expression result
+The second operand of the && operator has no impact on expression result
</td><td><pre>
void test() {
unsigned a;
- if (a<7 && a<10) {}; // warn
+ if (a<7 && a<10) {}; // warn
}
</pre></td><td></td></tr>
void test() {
int i=0;
if (i!=0) {}; // warn
- if (i==0 && i==1) {}; // warn
+ if (i==0 && i==1) {}; // warn
if (i<0 || i>=0) {}; // warn
}
</pre></td><td></td></tr>
<tr><td><span class="name">different.SameResUnsignedCmp
<br>(C)</span><br><br>
-Comparison of unsigned expression \91op expr\92 is always true/false
+Comparison of unsigned expression 'op expr' is always true/false
</td><td><pre>
void test() {
unsigned u;
<tr><td><span class="name">different.OpPrecedenceAssignCmp
<br>(C)</span><br><br>
Comparison operation has higher precedence then assignment. Bool value is
-assigned to variable of type \91type\92. Parenthesis may bee required around an
+assigned to variable of type 'type'. Parenthesis may bee required around an
assignment
</td><td><pre>
int f();
<br>(C++)</span><br><br>
The object was created but is not being used<br><br>
The exception object was created but is not being used. Did you mean
-\91throw std::exception();\92 ?
+'throw std::exception();'?
</td><td><pre>
#include <exception>
<tr><td><span class="name">different.ConversionToBool
<br>maybe join with experimental.core.BoolAssignment<br>(C, C++)</span><br><br>
-Odd implicit conversion from \91type\92 to \91bool\92
+Odd implicit conversion from 'type' to 'bool'
</td><td><pre>
bool test() {
return 1.; // warn
</table>
-<!------------------------------- WinAPI -------------------------------------->
+<!-- ============================ WinAPI =================================== -->
<h3>WinAPI</h3>
<table class="checkers">
<col class="namedescr"><col class="example"><col class="progress">
BOOL fSuccess;
fSuccess = CreateProcess(
NULL, TEXT("MyProgram.exe"), NULL, NULL,
- TRUE, 0, NULL, NULL, &si, &pi);
+ TRUE, 0, NULL, NULL, &si, &pi);
} // warn
</pre></td><td></td></tr>
</table>
-<!------------------------------ optimization --------------------------------->
+<!-- =========================== optimization ============================== -->
<h3>optimization</h3>
<table class="checkers">
<col class="namedescr"><col class="example"><col class="progress">
void test() {
const char* s = "abc";
- if (strlen(s) > 0 &&
+ if (strlen(s) > 0 &&
strlen(s) < 7) {}; // warn
}
</pre></td><td></td></tr>
<tr><td><span class="name">optimization.EmptyCstrDetect
<br>(C)</span><br><br>
-Optimization: it is more efficient to use \93str[0] != \91\0\92\94 to identify an empty
+Optimization: it is more efficient to use "str[0] != '\0'" to identify an empty
string
</td><td><pre>
#include <string.h>