[previous] 1473 [next] The 2nd and 3rd operands of this conditional operator (? :) are of different enum types.
Arithmetic type - Enum types REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers

The 2nd and 3rd operands of this conditional operator are objects or constants of different enumeration types. Is this intended ?

For example:


/*PRQA S 2017,2211,2213,3198,3199,3203,3227,3408,3447,3448,3602 ++*/

typedef enum { SMALL = 1, MEDIUM = 2, LARGE = 3 } SIZE;
typedef enum { RED = 2, GREEN = 4, BLUE = 6 }     COLOUR;

extern void foo(int n, COLOUR shade, SIZE box)
{
    COLOUR r;

    r = (n > 0) ? shade : box;                  /* Message 1473 */
    r = (n > 0) ? shade : SMALL;                /* Message 1473 */
    r = (n > 0) ? RED   : SMALL;                /* Message 1473 */

    return;
}

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