forked from github/codeql-coding-standards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
45 lines (39 loc) · 1.03 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <algorithm>
#include <vector>
void f1(std::vector<int> &v) {
{
auto i = v.begin();
++i; // NON_COMPLIANT
i = i++; // NON_COMPLIANT
i = i + 10; // NON_COMPLIANT
}
{
auto i = v.begin();
if (v.size() > 10) {
++i; // COMPLIANT
i = i++; // COMPLIANT
i = i + 10; // COMPLIANT
}
}
for (auto i = v.begin(),
l = (i + std::min(static_cast<std::vector<int>::size_type>(10),
v.size())); // NON_COMPLIANT - technically in the
// calculation
i != l; ++i) { // COMPLIANT
}
for (auto i = v.begin();; ++i) { // NON_COMPLIANT
}
}
void test_fp_reported_in_374(std::vector<int> &v) {
{
auto end = v.end();
for (auto i = v.begin(); i != end; ++i) { // COMPLIANT
}
}
{
auto end2 = v.end();
end2++; // NON_COMPLIANT
for (auto i = v.begin(); i != end2; ++i) { // NON_COMPLIANT[FALSE_NEGATIVE]
}
}
}