![]() |
![]() |
1470 | ![]() |
||||
![]() | |||||||
| Switch statements | REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers | ||||||
An integer constant is being used as a case label in a switch statement with a controlling expression of enum type. The C language allows this but it is not good practice. If the constant corresponds to one of the enum constants it would be better to use that instead. If it doesn't, the case statement will be unreachable under normal circumstances and message 1460 will be generated. For example:
/*PRQA S 1-9999 ++*/
/*PRQA S 1460, 1470 --*/
enum SIZE { small, medium, large };
int paint (enum SIZE box)
{
switch (box)
{
case small:
return 10;
case 1: /* Message 1470 */
return 30;
case 5: /* Message 1460 and 1470 */
return 20;
default:
return 0;
}
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |