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

Skip to content

Commit faa9d83

Browse files
committed
C++: Add testcase demonstrating false positive
1 parent bdd0589 commit faa9d83

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
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. |
1616
| test.cpp:113:6:113:10 | ... = ... | Use of '=' where '==' may have been intended. |
17+
| test.cpp:124:6:124:15 | ... = ... | Use of '=' where '==' may have been intended. |

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,11 @@ void h() {
116116

117117
void f() {
118118
h<int>();
119+
}
120+
121+
void f2() {
122+
const char* sz = "abc";
123+
124+
if(sz = "def") { // GOOD [FALSE POSITIVE]: a == comparison with a string literal is probably not the intent here
125+
}
119126
}

0 commit comments

Comments
 (0)