C++: Fix false positive

This commit is contained in:
Mathias Vorreiter Pedersen
2020-01-07 13:16:47 +01:00
parent 428e357488
commit bdd0589223
3 changed files with 2 additions and 3 deletions

View File

@@ -81,5 +81,6 @@ predicate candidateVariable(Variable v) {
from BooleanControllingAssignment ae, UndefReachability undef
where
candidateResult(ae) and
not ae.isFromUninstantiatedTemplate(_) and
not undef.reaches(_, ae.getLValue().(VariableAccess).getTarget(), ae.getLValue())
select ae, "Use of '=' where '==' may have been intended."

View File

@@ -13,6 +13,4 @@
| test.cpp:82:7:82:11 | ... = ... | Use of '=' where '==' may have been intended. |
| test.cpp:84:7:84:11 | ... = ... | Use of '=' where '==' may have been intended. |
| test.cpp:92:17:92:22 | ... = ... | Use of '=' where '==' may have been intended. |
| test.cpp:105:6:105:10 | ... = ... | Use of '=' where '==' may have been intended. |
| test.cpp:113:6:113:10 | ... = ... | Use of '=' where '==' may have been intended. |
| test.cpp:113:6:113:10 | ... = ... | Use of '=' where '==' may have been intended. |

View File

@@ -102,7 +102,7 @@ void g(int *i_p, int cond) {
template<typename>
void h() {
int x;
if(x = 0) { // GOOD [FALSE POSITIVE]: x is not initialized so this is probably intensional
if(x = 0) { // GOOD: x is not initialized so this is probably intensional
}
int y = 0;