Skip to content

Commit cee9f01

Browse files
committed
CTR55-CPP: improve testfile to doc an expected fp corner case
1 parent 87a623c commit cee9f01

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cpp/cert/test/rules/CTR55-CPP/DoNotUseAnAdditiveOperatorOnAnIterator.expected

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
| test.cpp:28:31:28:31 | i | Increment of iterator may overflow since its bounds are not checked. |
66
| test.cpp:41:5:41:8 | end2 | Increment of iterator may overflow since its bounds are not checked. |
77
| test.cpp:53:42:53:42 | i | Increment of iterator may overflow since its bounds are not checked. |
8+
| test.cpp:64:15:64:15 | i | Increment of iterator may overflow since its bounds are not checked. |

cpp/cert/test/rules/CTR55-CPP/test.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,14 @@ void test(std::vector<int> &v, std::vector<int> &v2) {
5353
for (auto i = v.begin(); i != end; ++i) { // NON_COMPLIANT - wrong check
5454
}
5555
}
56+
}
57+
58+
void test2(std::vector<int> &v) {
59+
auto i = v.begin();
60+
while (1) {
61+
auto i2 = ((i != v.end()) != 0);
62+
if (!i2)
63+
break;
64+
(void)((++i)); // COMPLIANT[FALSE_POSITIVE]
65+
}
5666
}

0 commit comments

Comments
 (0)