Skip to content

Commit e68352b

Browse files
committed
C++: Add testcase for false positive.
1 parent cafe55f commit e68352b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@
5050
| PointlessComparison.cpp:43:6:43:29 | ... >= ... | Comparison is always true because ... >> ... >= 140737488355327.5. |
5151
| PointlessComparison.cpp:44:6:44:28 | ... >= ... | Comparison is always true because ... >> ... >= 140737488355327.5. |
5252
| RegressionTests.cpp:57:7:57:22 | ... <= ... | Comparison is always true because * ... <= 4294967295. |
53+
| RegressionTests.cpp:125:7:125:11 | ... > ... | Comparison is always false because x <= 0. |
5354
| Templates.cpp:9:10:9:24 | ... <= ... | Comparison is always true because local <= 32767. |

cpp/ql/test/query-tests/Likely Bugs/Arithmetic/PointlessComparison/RegressionTests.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,11 @@ void negativeZero4(int val) {
116116
if (val == 0) // GOOD [NO LONGER REPORTED]
117117
;
118118
}
119+
120+
void f(int *const &ref_to_ptr);
121+
122+
void testTempObject() {
123+
int x = 0;
124+
f(&x);
125+
if (x > 0) {} // BAD [FALSE POSITIVE]
126+
}

0 commit comments

Comments
 (0)