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

Open
rvermeulen opened this issue Feb 9, 2024 · 0 comments
Labels
false positive/false negative An issue related to observed false positives or false negatives. user-report Issue reported by an end user of CodeQL Coding Standards

Comments

@rvermeulen
Copy link
Collaborator

rvermeulen commented Feb 9, 2024

Affected rules

  • cpp/autosar/function-missing-constexpr

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false positive/false negative An issue related to observed false positives or false negatives. user-report Issue reported by an end user of CodeQL Coding Standards
Projects
None yet
Development

No branches or pull requests

1 participant