AUTOSAR C++14 Rule A8-4-10
Description
Rule Definition
A parameter shall be passed by reference if it can't be NULL
Rationale
A reference cannot be NULL. If a parameter is required (it cannot be NULL), pass that parameter by reference to make your intent clearer. Passing by reference also yields cleaner code because you do not need to check whether the parameter is NULL before you use it.
Polyspace Implementation
Polyspace® flags passed-by-pointer parameters except if:
The pointer is a smart pointer such as
std::shared_ptr
.The pointer is not dereferenced in the function.
The pointer is checked against NULL, even if the check happens after the dereference.
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: Declarators |
Category: Required, Automated |
Version History
Introduced in R2021a