Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 15.7 and empty else statements without "else if"
#1
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;
void foo(bool_t x);
void foo(bool_t x) {
    if (x) {
        ;
    }  
    else { }
}
<t></t>


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)