Skip to content

M0-1-4: constexpr variable access in type argument is not considered a use #6

Closed
@lcartey

Description

@lcartey

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

Metadata

Metadata

Assignees

Labels

Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressImpact-Highfalse positive/false negativeAn issue related to observed false positives or false negatives.top-25-fpsuser-reportIssue reported by an end user of CodeQL Coding Standards

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions