AutosarC++18_03-A13.2.2¶
A binary arithmetic operator and a bitwise operator shall return a “prvalue”
Required inputs: IR
Bad code (returning reference to member):
class MyInt {
int value_;
public:
int& operator+(int rhs) { // ERROR: returns reference to member
value_ += rhs;
return value_;
}
};
Bad code (returning const qualified):
class MyInt {
int value_;
public:
const int operator+(int rhs) { // ERROR: returns const int
return value_ + rhs;
}
};
Good code (returning basic value):
class MyInt {
int value_;
public:
int operator+(int rhs) { return value_ + rhs; } // OK: returns by value
};
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
arith_bitwise_basic_value |
Binary arithmetic or bitwise operator shall return a basic value. |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
allow_bitwise_shift¶
allow_bitwise_shift : bool = True
operator>> or
operator<<.