![]() |
![]() |
1423 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Enum types | REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers | ||||||
An object of enum type is being used as a return expression but the function is of a different enum type. This is permitted in the C language but is it really intended ? It could result in an 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;
typedef enum color
{
red ,
white ,
black ,
violet } COLOUR;
extern void func1(TREE trp);
extern TREE tra;
extern COLOUR col;
extern TREE foo(void)
{
func1(col); /* Message 1421 */
tra = col; /* Message 1422 */
return(col); /* Message 1423 */
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |