[previous] 1441 [next] A non-constant expression of non-enum type is being passed as argument to a function parameter of enum type.
Arithmetic type - Enum types REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers

An expression which is not of enum type is being passed as an argument to a function parameter which is of enum type. This is permitted in the C language but is it really intended ? It could result in the enum object containing a value which is not a valid member of the enumeration.

For example:


/*PRQA S 1277,2006,2017,2201,2203,3198,3227,3408,3447,3448,3602 ++*/

typedef enum tree
{
    fir   ,
    cedar ,
    maple ,
    pine   } TREE;

extern void func1(TREE trp);

extern TREE   tra;

extern TREE foo(int mem)
{
   func1(mem);                     /* Message 1441 */
   tra = mem;                      /* Message 1442 */
   return(mem);                    /* Message 1443 */
}

See also:

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