![]() |
![]() |
0594 | ![]() |
||||
![]() | |||||||
| Switch statements | |||||||
A negative case label has been found in a switch statement in which the controlling expression is of an unsigned type. The case label will probably be unreachable. For example:
/*PRQA S 2017 ++*/
/*PRQA S 2017,3227,3352,3408,3447,3605 ++*/
extern int x;
void foo(unsigned int n)
{
switch ( n )
{
case -1: /* Messages 0594 and 0277*/
++x;
break;
default:
--x;
break;
}
}
MISRA C:2012 Rules applicable to message 0594:
| Rule-2.1 (Required) | A project shall not contain unreachable code |
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |