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

A0-1-1: initialization of constexpr used as NTTP is detected as useless assignment #728

Open
fjatWbyT opened this issue Oct 3, 2024 · 0 comments
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 Standard-AUTOSAR user-report Issue reported by an end user of CodeQL Coding Standards

Comments

@fjatWbyT
Copy link
Contributor

fjatWbyT commented Oct 3, 2024

Affected rules

  • A0-1-1 (useless assignment)

Description

Constant expression used as non-type template parameter (NTTP) produces useless-assignment false positive. It can be reproduced with integer NTTP.

Example

#include <ratio>

int main() {
  constexpr int one      = 1;     // True positive, this one is indeed unused (therefore, assignment is useless).
  constexpr int thirteen = 13;    // False positive, used in the second argument:
                                  // it can be verified that main returns 13.
  std::ratio<1, thirteen> ratio;
  return ratio.den;
}

Both definitions of one and thirteen are alerted as unused on query cpp/autosar/src/rules/A0-1-1/UselessAssignment.ql.

@fjatWbyT fjatWbyT added the false positive/false negative An issue related to observed false positives or false negatives. label Oct 3, 2024
@lcartey lcartey added the user-report Issue reported by an end user of CodeQL Coding Standards label Oct 15, 2024
@lcartey lcartey moved this from Reported to Triaged in Coding Standards Public Development Board Oct 23, 2024
@lcartey lcartey added Difficulty-Medium A false positive or false negative report which is expected to take 1-5 days effort to address Impact-Medium labels Oct 23, 2024
@lcartey lcartey linked a pull request Oct 23, 2024 that will close this issue
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 Standard-AUTOSAR user-report Issue reported by an end user of CodeQL Coding Standards
Projects
Development

No branches or pull requests

3 participants