[previous] 2008 [next] Code statements precede the first label in this 'switch' construct.
Redundancy REFERENCE - ISO:C90-6.6.4.2 The switch Statement - Semantics

An executable statement has been located before the first case label in this switch statement. This is unreachable code and the statement will never be executed.

Declarations are the only form of meaningful code that can precede the first case label but any attempted initialization will simply be ignored.

For example:


/*PRQA S 1-9999 ++*/
/*PRQA S 2008, 2880, 2882, 3234 --*/

extern int n;

void foo(int m)
{
    switch (m)        /* Message 2882 */
    {
        int j;        /* Message 3234 */
        int k = 2;
        n = n + 1;    /* Message 2008 and 2880 */

    case 1:
        --n;
        break;

    default:
        ++n;
        break;
    }
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents