File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
cpp/ql/test/query-tests/Likely Bugs/Arithmetic/PointlessComparison Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 5050| PointlessComparison.cpp:43:6:43:29 | ... >= ... | Comparison is always true because ... >> ... >= 140737488355327.5. |
5151| PointlessComparison.cpp:44:6:44:28 | ... >= ... | Comparison is always true because ... >> ... >= 140737488355327.5. |
5252| RegressionTests.cpp:57:7:57:22 | ... <= ... | Comparison is always true because * ... <= 4294967295. |
53+ | RegressionTests.cpp:131:17:131:25 | ... < ... | Comparison is always true because 43 <= ... + .... |
54+ | RegressionTests.cpp:135:26:135:52 | ... < ... | Comparison is always false because 16 >= ... * .... |
55+ | RegressionTests.cpp:140:50:140:61 | ... < ... | Comparison is always false because ... * ... >= 84. |
56+ | RegressionTests.cpp:154:21:154:31 | ... < ... | Comparison is always false because ... - ... >= 34. |
57+ | RegressionTests.cpp:154:21:154:31 | ... < ... | Comparison is always false because ... - ... >= 38. |
5358| Templates.cpp:9:10:9:24 | ... <= ... | Comparison is always true because local <= 32767. |
Original file line number Diff line number Diff line change @@ -124,3 +124,34 @@ void testTempObject() {
124124 f (&x);
125125 if (x > 0 ) {} // GOOD [NO LONGER REPORTED]
126126}
127+
128+ void staticAssert () {
129+ static const int a = 42 ;
130+ static const int b = 43 ;
131+ static_assert (a < b + 0 , " " ); // GOOD [FALSE POSITIVE]
132+ }
133+
134+ constexpr int global_1 = 42 ;
135+ constexpr int global_2 = global_1 < 2 * sizeof (int *) ? 43 : 2 * sizeof (int *); // GOOD [FALSE POSITIVE]
136+
137+ static const int global_3 = 42 ;
138+ static const int global_4 = global_3 < 2 * sizeof (int *) ? 43 : 2 * sizeof (int *); // GOOD
139+
140+ template <unsigned int p, unsigned int n, bool = ((2u * n) < p)>
141+ struct templateCompare : public templateCompare <p, 2u * n> // GOOD [FALSE POSITIVE]
142+ { };
143+
144+ template < unsigned int p, unsigned int n>
145+ struct templateCompare < p, n, false >
146+ {
147+ static const unsigned int v = n;
148+ };
149+
150+ unsigned int templateCompare_x = templateCompare<42 , 42 >::v;
151+
152+ template <int n>
153+ struct someType {
154+ typedef someType<((n - 4 ) < 0 ? 0 : n - 4 )> b; // GOOD [FALSE POSITIVE]
155+ };
156+
157+ someType<42 >::b someType_x;
You can’t perform that action at this time.
0 commit comments