[previous] 1476 [next] Range of possible enum values suggests this test is always false.
Enumerations REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers

The value of an object of enum type is being compared with the value of a constant expression. Assuming that the value of the object corresponds to a valid enum constant, the result of this comparison will always be 'false'.

For example:


/*PRQA S 1-9999 ++*/
/*PRQA S 1475, 1476 --*/

enum EC { RED, BLUE, GREEN };

extern int foo(enum EC ex)
{
    int r;
    int x = 10;

    r = ex >= RED;                              /* Message 1475 */
    r = ex < 10;                                /* Message 1475 */
    r = ex < x;                                 /*              */

    r = ex < RED;                               /* Message 1476 */
    r = ex > 10;                                /* Message 1476 */
    r = ex > x;                                 /*              */

    return r;
}

See also:

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