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

Skip to content

Commit d39d9bf

Browse files
committed
CPP: Workaround FPs.
1 parent 185ca59 commit d39d9bf

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

cpp/ql/src/Likely Bugs/UseInOwnInitializer.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ where va.initializesItself(v, init)
3232
exists (CrementOperation crement | crement.getAnOperand() = va)
3333
)
3434
and not va.isUnevaluated()
35+
and not v.isConst()
3536
and not (
3637
va.getParent() = init and
3738
exists(MacroInvocation mi |

cpp/ql/test/query-tests/Likely Bugs/UseInOwnInitializer/UseInOwnInitializer.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,3 @@
22
| test.cpp:8:10:8:10 | x | x is used in its own initializer. |
33
| test.cpp:57:10:57:10 | x | x is used in its own initializer. |
44
| test.cpp:61:24:61:24 | x | x is used in its own initializer. |
5-
| test.cpp:80:17:80:23 | v2 | v2 is used in its own initializer. |
6-
| test.cpp:84:16:84:22 | v4 | v4 is used in its own initializer. |
7-
| test.cpp:89:17:89:23 | v6 | v6 is used in its own initializer. |
8-
| test.cpp:90:17:90:23 | v7 | v7 is used in its own initializer. |

cpp/ql/test/query-tests/Likely Bugs/UseInOwnInitializer/test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ namespace ns1
7777
namespace ns2
7878
{
7979
const int v1 = ns1::v2; // GOOD
80-
const int v2 = ns1::v2; // GOOD [FALSE POSITIVE; produces INVALID_KEY trap warning]
80+
const int v2 = ns1::v2; // GOOD [produces INVALID_KEY trap warning]
8181
};
8282

8383
const int v3 = ns1::v4; // GOOD
84-
const int v4 = ns1::v4; // GOOD [FALSE POSITIVE]
84+
const int v4 = ns1::v4; // GOOD
8585

8686
namespace ns3
8787
{
8888
const int v5 = ns1::v6 + 1; // GOOD
89-
const int v6 = ns1::v6 + 1; // GOOD [FALSE POSITIVE; produces INVALID_KEY trap warning]
90-
const int v7 = ns3::v7; // BAD
89+
const int v6 = ns1::v6 + 1; // GOOD [produces INVALID_KEY trap warning]
90+
const int v7 = ns3::v7; // BAD [NOT DETECTED]
9191
};

0 commit comments

Comments
 (0)