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

All execution paths through a function with non-void return type must have an explicit return statement with a value. If a code path reaches the end of the function without returning a value, the function returns an uninitialized (garbage) value, causing undefined behavior. Every path must explicitly return a valid value.
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

exclude_missing_return_for_main

exclude_missing_return_for_main : bool = False

If True, no message for a missing return in main() will be reported.