AUTOSAR C++14 Rule A5-10-1
A pointer to member virtual function shall only be tested for equality with null-pointer-constant
Since R2020b
Description
Rule Definition
A pointer to member virtual function shall only be tested for equality with null-pointer-constant.
Rationale
A call to a member virtual function is resolved by the compiler at run-time to the most
derived version of the function. If you use the equality operators (==
)
or (!=
) to compare anything other than the null-pointer constant
nullptr
with a pointer to a member virtual function, the result is
unspecified.
Polyspace Implementation
Polyspace® flags any (==
) or (!=
) comparison where
one operand is a pointer to a member virtual function and the other operand is not
nullptr
.
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: Expressions |
Category: Required, Automated |
Version History
Introduced in R2020b