Main Content
AUTOSAR C++14 Rule A13-2-3
Description
Rule Definition
A relational operator shall return a boolean value.
Rationale
The return value from relational operators of the C++ Standard Library can be directly checked to see if a relation is true or false. Overloads of the relational operator must be consistent with this usage. Otherwise, users of the overloaded relational operator might see unexpected results. See example below.
Polyspace Implementation
The checker flags overloads of relational operators that do not return a value of type
bool
.
Troubleshooting
If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Overloading |
Category: Required, Automated |
Version History
Introduced in R2020a