MISRA C:2012 Rule 17.4
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
If a non-void
function does not explicitly return a value but the calling
function uses the return value, the behavior is undefined. To prevent this behavior:
You must provide
return
statements with an explicit expression.You must ensure that during run time, at least one
return
statement executes.
As an exception, lacking an explicit return
statement in your main()
function is compliant with this rule if
you use C99 or later.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Function |
Category: Mandatory |
AGC Category: Mandatory |