Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MISRA C++ 2008 Rule 6-1-1 Clarification
#1
Given the headline text of MISRA C++ 2008 Rule 6-1-1, MISRA C++ 2023 Rule 9.6.2 seems to be the equivalent rule in this case. MISRA C++ 2023 Rule 9.6.2 includes the following non-compliant example: 
Code:
switch(i)
{
    case 0:
      if(x < y)
        goto L3;            // Non-compliant
      break;

    case 1:
    L3:
      break;
}

This example seems to echo an amplification made in the MISRA C 2012 Rule 15.3 (that has the same headline text as MISRA C++ 2008 Rule 6-1-1), which states: 
  • Quote:For the purposes of this rule, a switch-clause that does not consist of a compound statement is treated as if it were a block.


It would be greatly appreciated if you could clarify whether the above example was also intended to violate MISRA C++ Rule 6-1-1.
Reply
#2
Unfortunately, for this example the wording in MISRA C++::2008 6-6-1 is ambiguous.

As you can see from the example from MISRA C++::2023 9.6.2, our intension is that this should be non-compliant. Indeed the rewording from 6-6-1 to 9.6.2 is to remove this ambiguity
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)