codeql-coding-standards
codeql-coding-standards copied to clipboard
`A7-1-2`: Qualifier cannot be declared `constexpr`
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;
}