AUTOSAR C++14 Rule A8-4-9
Description
Rule Definition
"in-out" parameters declared as T & shall be modified.
Rationale
A function parameter meant to be both read and modified within a function is called an "in-out" parameter.
If you do not both read and modify a parameter, avoid passing by
          non-const reference so that the function prototype reflects the true
        nature of the parameter.
- If you only read a parameter within a function, the parameter is actually an "in" parameter. - Pass the parameter by - constreference.
- If you replace the entire contents of a parameter within a function, the parameter is actually an "out" parameter. - If possible, avoid "out" parameters completely and store any output of the function in the function return value. See also - AUTOSAR C++14 Rule A8-4-8.
Polyspace Implementation
The checker checks each function parameter passed by non-const
        reference and raises a violation if the parameter is only read within the function or its
        value completely replaced within the function.
The checker does not raise a violation if:
- The parameter is an object and you access one or more of its data members, or invoke a non- - constmember function.
- You pass a pointer or reference to the parameter on to another function. 
- The function is virtual. The reason is that even if the current function might not modify its parameter, an override of the function might modify its corresponding parameter. 
- The function is an unused class method. 
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