Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lcartey opened this issue Oct 2, 2023 · 0 comments · Fixed by #538
Closed

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

lcartey opened this issue Oct 2, 2023 · 0 comments · Fixed by #538
Assignees
Labels
Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium user-report Issue reported by an end user of CodeQL Coding Standards

Comments

@lcartey
Copy link
Collaborator

lcartey commented Oct 2, 2023

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; }
@lcartey lcartey added false positive/false negative An issue related to observed false positives or false negatives. Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address Impact-Low user-report Issue reported by an end user of CodeQL Coding Standards Impact-Medium and removed Impact-Low labels Oct 2, 2023
@rvermeulen rvermeulen self-assigned this Feb 8, 2024
@rvermeulen rvermeulen mentioned this issue Feb 16, 2024
30 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium user-report Issue reported by an end user of CodeQL Coding Standards
Projects
Development

Successfully merging a pull request may close this issue.

2 participants