mirror of
https://github.com/github/codeql.git
synced 2025-12-24 12:46:34 +01:00
C++: Add testcase demonstrating false positive
This commit is contained in:
@@ -13,3 +13,6 @@
|
||||
| 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. |
|
||||
|
||||
@@ -98,3 +98,22 @@ void g(int *i_p, int cond) {
|
||||
if (y = 1) { // GOOD: y might not be initialized so it is probably intentional.
|
||||
}
|
||||
}
|
||||
|
||||
template<typename>
|
||||
void h() {
|
||||
int x;
|
||||
if(x = 0) { // GOOD [FALSE POSITIVE]: x is not initialized so this is probably intensional
|
||||
}
|
||||
|
||||
int y = 0;
|
||||
if((y = 1)) { // GOOD
|
||||
}
|
||||
|
||||
int z = 0;
|
||||
if(z = 1) { // BAD
|
||||
}
|
||||
}
|
||||
|
||||
void f() {
|
||||
h<int>();
|
||||
}
|
||||
Reference in New Issue
Block a user