Skip to content

Commit 9d14a85

Browse files
committed
C++: Add false positive.
1 parent b49ca6a commit 9d14a85

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

cpp/ql/test/query-tests/Likely Bugs/Arithmetic/BadAdditionOverflowCheck/PointlessSelfComparison.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
| templates.cpp:17:5:17:25 | ... < ... | Self comparison. |
2+
| templates.cpp:31:20:31:41 | ... <= ... | Self comparison. |
23
| test.cpp:13:11:13:21 | ... == ... | Self comparison. |
34
| test.cpp:79:11:79:32 | ... == ... | Self comparison. |
45
| test.cpp:83:10:83:15 | ... == ... | Self comparison. |

cpp/ql/test/query-tests/Likely Bugs/Arithmetic/BadAdditionOverflowCheck/templates.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,22 @@ bool compareValues() {
2020
bool callCompareValues() {
2121
return compareValues<C1, C2> || compareValues<C1, C1>();
2222
}
23+
24+
template <bool C, typename T = void>
25+
struct enable_if {};
26+
27+
template <typename T>
28+
struct enable_if<true, T> { typedef T type; };
29+
30+
template<typename T1, typename T2>
31+
typename enable_if<T1::value <= T2::value, bool>::type constant_comparison() {
32+
return true;
33+
}
34+
35+
struct Value0 {
36+
const static int value = 0;
37+
};
38+
39+
void instantiation_with_pointless_comparison() {
40+
constant_comparison<Value0, Value0>();
41+
}

0 commit comments

Comments
 (0)