Skip to content

A0-1-1: auto local variables in uninstantiated templates are reported as unused #230

Closed
@lcartey

Description

@lcartey

Affected rules

  • A0-1-1

Description

Where an auto variable is declared in a template function or class, the copy of the variable in the uninstantiated template may be considered "unused", even though it is considered used in at least one instantiation.

Example

#include <vector>
template <typename T> void test_range_based_for_loop_template() {
  std::vector<A> values_;
  for (auto &elem : values_) { // COMPLIANT - should not report either elem or
                               //             the compiler generated (__range)
                               //             variable in the uninstantiated
                               //             template
    elem;
  }
}

// Instantiate the template
void test_template() { test_range_based_for_loop_template<A>(); }

Metadata

Metadata

Assignees

Labels

Difficulty-MediumA false positive or false negative report which is expected to take 1-5 days 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