Skip to content

A5-1-1: Exclude literals generated for template instantiations #371

Closed
@lcartey

Description

@lcartey

Affected rules

  • A5-1-1

Description

Template instantiations with literal arguments can cause the creation of generated Literals in the program in two ways:

  1. If the template argument was a constexpr, we may generate a Literal expression to represent the compiler-calculated value.
  2. If the template argument is used as an expression, we will generate a Literal at that location to hold the value of the compiler-calculated value.

Example

#include <limits>
constexpr std::size_t dynamic_extent = std::numeric_limits<std::size_t>::max();

template <typename _Type, std::size_t _Extent = dynamic_extent> class span {
  static constexpr std::size_t extent = _Extent;
};

void test_extent() { span<int> s; }

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