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: Alert on move constructor declaration that cannot be constexpr specified #529

Closed
rvermeulen opened this issue Feb 9, 2024 · 2 comments
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address Impact-Medium Standard-AUTOSAR user-report Issue reported by an end user of CodeQL Coding Standards

Comments

@rvermeulen
Copy link
Collaborator

rvermeulen commented Feb 9, 2024

Affected rules

  • A7-1-2

Description

The query alerts on a move constructor declaration outside the class body.
Per [dcl.constexpr] paragraph 1, a constexpr shall only be applied to the declaration of a function with the additional constraint that all of its declarations shall contain the constexpr. When the advice associated with the alert is followed, this results in the compilation error:

error: constexpr declaration of 'MyClass' follows non-constexpr declaration

Example

File: myclass.hpp

class MyClass {
 public:
  ...
  MyClass(MyClass&&) noexcept;
  ...
 private:
  int data;
}

File: myclass.cpp

MyClass::MyClass(MyClass&&) noexcept = default;
@rvermeulen rvermeulen added the false positive/false negative An issue related to observed false positives or false negatives. label Feb 9, 2024
@rvermeulen rvermeulen changed the title A7-1-2: Incorrecly flag move constructor definition A7-1-2: Alert on move constructor declaration that cannot be constexpr specified Feb 9, 2024
@rvermeulen rvermeulen added the user-report Issue reported by an end user of CodeQL Coding Standards label Feb 21, 2024
@lcartey lcartey removed the false positive/false negative An issue related to observed false positives or false negatives. label Dec 10, 2024
@lcartey lcartey moved this from Reported to Triaged in Coding Standards Public Development Board Dec 10, 2024
@lcartey lcartey added Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address Impact-Medium labels Dec 10, 2024
@lcartey
Copy link
Collaborator

lcartey commented Dec 10, 2024

I believe this is a reporting issue, and not a false positive. The query should report that all declarations of a function need to be changed to include constexpr. The message could be adapted as follows:

"The function " + ecef.getName() + " and all declarations could be marked as 'constexpr'."

@lcartey
Copy link
Collaborator

lcartey commented Jan 21, 2025

Closing as not planned as we have determined we should not report functions under this rule (#843).

@lcartey lcartey closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2025
@lcartey lcartey moved this from Done to Closed (Duplicate) in Coding Standards Public Development Board Jan 21, 2025
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 Impact-Medium Standard-AUTOSAR user-report Issue reported by an end user of CodeQL Coding Standards
Projects
Status: Closed (Duplicate)
Development

No branches or pull requests

3 participants