Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 6-3-1: Does it also apply to "case" blocks?
#1
Consider this piece of code:

Code:
enum Foo
{
  a,
  b
};


void foo(Foo f)
{
  switch(f)
  {
    case a:
      std::cout << "a\n";
      break;
    case b:
      std::cout << "b\n";
      break;
  }

}

Is the above compliant with M6-3-1, or does one need to add braces also to the "case" blocks, e.g.:

Code:
case a:
{
  std::cout << "a\n";
  break;
}

Thanks!
Reply
#2
No, braces are not required around the case clause, see switch syntax in 6-4-3
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)