Skip to content

M0-1-3: Local variables that are used are reported as unused #658

Closed
@rak3-sh

Description

@rak3-sh

Affected rules

  • M0-1-3

Description

Local variables that are used are reported as unused. Please refer to the example for the sample scenarios.

Example

int foo()
{
  constexpr int arrayDim=10; // 'arrayDim' reported unused
  static int array[arrayDim] {}; // 'arrayDim' is used here
  return array[4];
}

template<typename T>
static T template_function()
{
  return T();
}

template<typename T, typename First, typename... Rest>           
static T template_function(const First& first, const Rest&... rest) // 'rest' reported unused
{
  return first + template_function<T>(rest...); // 'rest' is used here
}

static int templ_fnc2() {
  return template_function<int>(1, 2, 3, 4, 5);
}

int main()
{
  return 0;
}

Metadata

Metadata

Assignees

Labels

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

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions