Skip to content

A7-1-2: Alert on move constructor declaration that cannot be constexpr specified #529

@rvermeulen

Description

@rvermeulen

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressImpact-MediumStandard-AUTOSARuser-reportIssue reported by an end user of CodeQL Coding Standards

    Type

    No type

    Projects

    Status

    Closed (Duplicate)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions