05-05-2023, 02:16 PM
The compound statement that forms the body of the function refers to the outer { } braces of the function - not any inner compound statement.
Therefore, your first example violates R.15.5 - it also violates Mandatory R.17.4 as there is no return statement in the path when the condition is false.
In your second example, a labelled-statement is formed by an id followed by a statement - therefore, the use of a labelled return is not a violation or R.15.5
Therefore, your first example violates R.15.5 - it also violates Mandatory R.17.4 as there is no return statement in the path when the condition is false.
In your second example, a labelled-statement is formed by an id followed by a statement - therefore, the use of a labelled return is not a violation or R.15.5
Posted by and on behalf of the MISRA C Working Group