Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A7-1-2: constexpr in templates #609

Open
Labels
Difficulty-HighA false positive or false negative report which is expected to take 1+ week effort to address Impact-Low Standard-AUTOSAR false positive/false negativeAn issue related to observed false positives or false negatives. user-reportIssue reported by an end user of CodeQL Coding Standards
@lcartey

Description

Affected rules

  • A7-1-2

Description

We should only report a variable in a template as a candidate for adding constexpr if all visible instantiations could use constexpr.

Example

int x;
constexpr int* init_t(int i) {
 return &x;
}
float* init_t(float f) {
 return new float();
}
template <typename T> void constexpr_variable_template() {
 constexpr T t1{};
 T* t = init_t(t1); // COMPLIANT[FALSE_POSITIVE] for int, this could be constexpr, but not for float
}
void test() {
 constexpr_variable_template<int>();
 constexpr_variable_template<float>();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty-HighA false positive or false negative report which is expected to take 1+ week effort to address Impact-Low Standard-AUTOSAR false positive/false negativeAn issue related to observed false positives or false negatives. user-reportIssue reported by an end user of CodeQL Coding Standards

    Type

    No type

    Projects

    Status

    Triaged

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /