mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
C++: Add cpp/constant-comparison FP test cases after frontend update
This commit is contained in:
@@ -50,4 +50,9 @@
|
||||
| PointlessComparison.cpp:43:6:43:29 | ... >= ... | Comparison is always true because ... >> ... >= 140737488355327.5. |
|
||||
| PointlessComparison.cpp:44:6:44:28 | ... >= ... | Comparison is always true because ... >> ... >= 140737488355327.5. |
|
||||
| RegressionTests.cpp:57:7:57:22 | ... <= ... | Comparison is always true because * ... <= 4294967295. |
|
||||
| RegressionTests.cpp:131:17:131:25 | ... < ... | Comparison is always true because 43 <= ... + .... |
|
||||
| RegressionTests.cpp:135:26:135:52 | ... < ... | Comparison is always false because 16 >= ... * .... |
|
||||
| RegressionTests.cpp:140:50:140:61 | ... < ... | Comparison is always false because ... * ... >= 84. |
|
||||
| RegressionTests.cpp:154:21:154:31 | ... < ... | Comparison is always false because ... - ... >= 34. |
|
||||
| RegressionTests.cpp:154:21:154:31 | ... < ... | Comparison is always false because ... - ... >= 38. |
|
||||
| Templates.cpp:9:10:9:24 | ... <= ... | Comparison is always true because local <= 32767. |
|
||||
|
||||
@@ -124,3 +124,34 @@ void testTempObject() {
|
||||
f(&x);
|
||||
if (x > 0) {} // GOOD [NO LONGER REPORTED]
|
||||
}
|
||||
|
||||
void staticAssert() {
|
||||
static const int a = 42;
|
||||
static const int b = 43;
|
||||
static_assert(a < b + 0, ""); // GOOD [FALSE POSITIVE]
|
||||
}
|
||||
|
||||
constexpr int global_1 = 42;
|
||||
constexpr int global_2 = global_1 < 2 * sizeof(int*) ? 43 : 2 * sizeof(int*); // GOOD [FALSE POSITIVE]
|
||||
|
||||
static const int global_3 = 42;
|
||||
static const int global_4 = global_3 < 2 * sizeof(int*) ? 43 : 2 * sizeof(int*); // GOOD
|
||||
|
||||
template<unsigned int p, unsigned int n, bool = ((2u * n) < p)>
|
||||
struct templateCompare : public templateCompare<p, 2u * n> // GOOD [FALSE POSITIVE]
|
||||
{ };
|
||||
|
||||
template< unsigned int p, unsigned int n>
|
||||
struct templateCompare< p, n, false>
|
||||
{
|
||||
static const unsigned int v = n;
|
||||
};
|
||||
|
||||
unsigned int templateCompare_x = templateCompare<42, 42>::v;
|
||||
|
||||
template<int n>
|
||||
struct someType {
|
||||
typedef someType<((n - 4) < 0 ? 0 : n - 4)> b; // GOOD [FALSE POSITIVE]
|
||||
};
|
||||
|
||||
someType<42>::b someType_x;
|
||||
|
||||
Reference in New Issue
Block a user