Closed
Description
Affected rules
M0-1-4
Description
constexpr
variables used as a type argument are not recognised as a use of that variable, and therefore cause false positives. This is because constant expressions used as type arguments are stored in the database fully evaluated. Access of constant variable is therefore replaced with the constant value.
This may require a CodeQL extractor change if no use information is currently stored in the database.
Example
In this example:
class C1 {
static constexpr std::uint8_t size{2}; // COMPLIANT[FALSE_POSITIVE]
std::array<bool, size> array{ false, false }; // size is used here
};
size
is used as a template argument for std::array
. However, the type represented in the database is array<bool, 2UL>
, because