[previous] 1433 [next] An enum object is being returned from a function with a non-enum return type.
Arithmetic type - Enum types REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers

An enum object is being used as the return expression in a function which is not defined with enum type.

This is perfectly legal, but perhaps the function should be defined with enum type ?

For example:


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

typedef enum TC { red, green, blue, yellow } COLOUR;

extern void foo1(int container);

extern int foo2(COLOUR paper)
{
    int box;

    box = paper;                /* Message 1432 - enum object assigned to int object     */
    foo1(paper);                /* Message 1431 - enum object passed to int parameter    */
    return paper;               /* Message 1433 - enum object returned from int function */
}

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