File tree Expand file tree Collapse file tree
cpp/ql/test/query-tests/Likely Bugs/Arithmetic/PointlessComparison Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ void func_with_default_arg (const int n = 0 ) {
2+ if (n <= 10 ) {} // GOOD [FALSE POSITIVE]
3+ }
4+
5+ struct A {
6+ const int int_member = 0 ;
7+ A (int n) : int_member(n) {
8+ if (int_member <= 10 ) {
9+
10+ }
11+ }
12+ };
13+
14+ struct B {
15+ B (const int n = 0 ) {
16+ if (n <= 10 ) {} // GOOD [FALSE POSITIVE]
17+ }
18+ };
19+
20+ const volatile int volatile_const_global = 0 ;
21+
22+ void test1 () {
23+ func_with_default_arg (100 );
24+
25+ A a (100 );
26+ if (a.int_member <= 10 ) {}
27+
28+ if (volatile_const_global <= 10 ) {} // GOOD [FALSE POSITIVE]
29+ }
Original file line number Diff line number Diff line change 3838| PointlessComparison.c:303:9:303:14 | ... >= ... | Comparison is always false because c <= 0. |
3939| PointlessComparison.c:312:9:312:14 | ... >= ... | Comparison is always false because c <= 0. |
4040| PointlessComparison.c:337:14:337:21 | ... >= ... | Comparison is always true because x >= 0. |
41+ | PointlessComparison.cpp:2:8:2:14 | ... <= ... | Comparison is always true because n <= 0. |
42+ | PointlessComparison.cpp:16:12:16:18 | ... <= ... | Comparison is always true because n <= 0. |
43+ | PointlessComparison.cpp:28:8:28:34 | ... <= ... | Comparison is always true because volatile_const_global <= 0. |
4144| RegressionTests.cpp:57:7:57:22 | ... <= ... | Comparison is always true because * ... <= 4294967295. |
4245| Templates.cpp:9:10:9:24 | ... <= ... | Comparison is always true because local <= 32767. |
You can’t perform that action at this time.
0 commit comments