Rule 15.7 and empty else statements without "else if" - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21) +---- Forum: 8.15 Control flow (https://forum.misra.org.uk/forumdisplay.php?fid=170) +---- Thread: Rule 15.7 and empty else statements without "else if" (/showthread.php?tid=1381) |
Rule 15.7 and empty else statements without "else if" - rgamble - 17-10-2017 MISRA C 2012 Rule 15.7 states in the amplification that "The else statement shall contain at least either one side effect or a comment." Does "The else statement" refers to any else statement or just the final else statement that is required by the rule when there are one or more "else if" statements? Is the following example a violation of Rule 15.7 because the else statement does not contain a side effect or comment or is it compliant because the else is not required by the rule? Code: typedef _Bool bool_t; Re: Rule 15.7 and empty else statements without "else if" - misra-c - 07-12-2017 "The else statement" refers to the final else statement in a "if .. else if" construct. Rule 15.7 does not apply to the above example because there is no "if... else if" construct in the example. No comment or side effect is required in this case. |