Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A6-4-1 What is the definition of a "case-clause"?
#2
Your static analyser is strictly correct in flagging a violation in your example. "case-clause” is the case label and associated code.

The rule as written was considering a switch with a single case-label and default. However, as your example illustrates, if you have multiple values to test, the switch statement is clearer than the if. This has been recognized and would be accepted as grounds for a deviation. Indeed, you may find that your static analyser has a flag that prevents it raising violations in code like your example.
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Messages In This Thread
RE: A6-4-1 What is the definition of a "case-clause"? - by misra cpp - 27-10-2023, 03:39 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)