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

A7-1-2: Consider constexpr function behaviour #466

Closed
lcartey opened this issue Dec 1, 2023 · 0 comments · Fixed by #520
Closed

A7-1-2: Consider constexpr function behaviour #466

lcartey opened this issue Dec 1, 2023 · 0 comments · Fixed by #520
Assignees
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day 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 Dec 1, 2023

Affected rules

  • A7-1-2

Description

A constexpr function only returns a compile-time constant when provided with compile-time constants as arguments. The query currently incorrectly considers constexpr functions to always return constants.

Example

This function should only be considerd

constexpr int add(int x, int y) {
  return x + y;
}

void test(int p) {
  int x = add(1,2); // NON_COMPLIANT - could be marked constexpr
  int y = add(1,p); // COMPLIANT - cannot be marked constexpr
@lcartey lcartey added Difficulty-Low A false positive or false negative report which is expected to take <1 day 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 labels Dec 1, 2023
@rvermeulen rvermeulen self-assigned this Jan 23, 2024
@rvermeulen rvermeulen mentioned this issue Feb 1, 2024
30 tasks
github-merge-queue bot pushed a commit that referenced this issue Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day 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