Qt-Autosar-A8.4.2¶
All exit paths from a function with non-void return type shall have an explicit return statement with an expression
Required inputs: IR
Bad code (missing return on some paths):
int GetValue(bool flag) {
if (flag) {
return 42;
}
// ERROR: if flag is false, no return statement
}
Good code (all paths return):
int GetValue(bool flag) {
if (flag) {
return 42;
}
return 0; // OK: all paths have explicit return
}
bool IsEven(int n) {
return (n % 2) == 0; // OK: simple expression returns
}
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
lambda_return_missing_value |
Return without value in non-void lambda expression |
None |
False |
missing_return |
Non-void function needs return with value at end. |
None |
False |
missing_return_in_lambda |
Non-void lambda expression needs return with value at end. |
None |
False |
return_missing_value |
Return without value in non-void function |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
exclude_missing_return_for_main¶
exclude_missing_return_for_main : bool = False