AUTOSAR C++14 Rule A8-4-2
All exit paths from a function with non-void return type shall have an explicit return statement with an expression
Description
Rule Definition
All exit paths from a function with non-void return type shall have an explicit return statement with an expression.
Rationale
When you omit a return statement from a function with nonvoid return type, the function returns an undefined value. The undefined value can cause undefined behavior and unexpected results during code execution.
Polyspace Implementation
Polyspace® reports a rule violation when you do not include a return statement in every execution path of a function with nonvoid return type.
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 R2019a