[previous] 2009 [next] This 'default' label is not the final 'case' label within the 'switch' block.
Switch statements

This 'default' clause is not the final clause in the switch statement. This is quite legal but rather unconventional.

For example:


/*PRQA S 2017,3120,3227,3408 ++*/

extern int foo(int n)
{
    int r;

    switch (n)
    {
    default:                            /* Message 2009 */
        r = 0;
        break;

    case 1:
        r = 5;
        break;

    case 3:
        r = 10;
        break;

    case 5:
        r = 20;
        break;
    }

    return r;
}

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