Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
15.2 and 'break's inside if-else
#2
Yes, this does violate Rule 15.2 because the break statements are conditionally-executed, even though there is a break on both paths from the case label. The headline requires an unconditional break.

The normative rationale also states that the last statement in every switch clause shall be break statement or, if the last statement is a compound statement then break shall be the last statement in that compound statement. In the example given, the last statement in the switch clause is the if statement.

Finally, the syntax given in Rule 15.0, which supports all the rules in this section, is clear that the break statement must be the final, unconditionally-executed statement in a switch clause.
Posted by and on behalf of the MISRA C Working Group
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)