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: Qualifier cannot be declared constexpr #85

Closed
jsinglet opened this issue Sep 14, 2022 · 2 comments
Closed

A7-1-2: Qualifier cannot be declared constexpr #85

jsinglet opened this issue Sep 14, 2022 · 2 comments
Labels
false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium Standard-AUTOSAR

Comments

@jsinglet
Copy link
Contributor

jsinglet commented Sep 14, 2022

Affected rules

  • A7-1-2

Description

False positive reported for the following test case. In the example, below, a712 must be constexpr for value to be declared constexpr. However, it is not possible to declare parameters (easily) as constexpr. The mitigation for this issue is likely that cases where it is not possible to declare the qualifier as constexpr.

Example

class A7_1_2 {
 public:
  constexpr auto GetValue() const noexcept { return value_; }
  void SetValue(int32_t value) noexcept { value_ = value; }
 private:
  int32_t value_;
};
std::ostream &operator<<(std::ostream &os, const A7_1_2 a712) noexcept {
  const auto value = a712.GetValue(); // Variable value could be marked 'constexpr'.
  os << value;
  return os;
}
@jsinglet jsinglet added the false positive/false negative An issue related to observed false positives or false negatives. label Sep 14, 2022
@jsinglet jsinglet changed the title A7-1-2: <descri A7-1-2: Qualifier cannot be declared constexpr Sep 14, 2022
@lcartey
Copy link
Collaborator

lcartey commented Dec 10, 2024

This is a duplicate of #789, and has been fixed by #794.

@lcartey
Copy link
Collaborator

lcartey commented Dec 10, 2024

Note: this is because we previously weren't considering whether the qualifier to a call could be a compile-time constant.

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. Impact-Medium Standard-AUTOSAR
Projects
Development

No branches or pull requests

3 participants