Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bdd0589

Browse files
committed
C++: Fix false positive
1 parent 428e357 commit bdd0589

3 files changed

Lines changed: 2 additions & 3 deletions

File tree

cpp/ql/src/Likely Bugs/Likely Typos/AssignWhereCompareMeant.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,6 @@ predicate candidateVariable(Variable v) {
8181
from BooleanControllingAssignment ae, UndefReachability undef
8282
where
8383
candidateResult(ae) and
84+
not ae.isFromUninstantiatedTemplate(_) and
8485
not undef.reaches(_, ae.getLValue().(VariableAccess).getTarget(), ae.getLValue())
8586
select ae, "Use of '=' where '==' may have been intended."

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/AssignWhereCompareMeant/AssignWhereCompareMeant.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,4 @@
1313
| test.cpp:82:7:82:11 | ... = ... | Use of '=' where '==' may have been intended. |
1414
| test.cpp:84:7:84:11 | ... = ... | Use of '=' where '==' may have been intended. |
1515
| test.cpp:92:17:92:22 | ... = ... | Use of '=' where '==' may have been intended. |
16-
| test.cpp:105:6:105:10 | ... = ... | Use of '=' where '==' may have been intended. |
17-
| test.cpp:113:6:113:10 | ... = ... | Use of '=' where '==' may have been intended. |
1816
| test.cpp:113:6:113:10 | ... = ... | Use of '=' where '==' may have been intended. |

cpp/ql/test/query-tests/Likely Bugs/Likely Typos/AssignWhereCompareMeant/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void g(int *i_p, int cond) {
102102
template<typename>
103103
void h() {
104104
int x;
105-
if(x = 0) { // GOOD [FALSE POSITIVE]: x is not initialized so this is probably intensional
105+
if(x = 0) { // GOOD: x is not initialized so this is probably intensional
106106
}
107107

108108
int y = 0;

0 commit comments

Comments
 (0)