![]() |
![]() |
1317 | ![]() |
||||
![]() | |||||||
| Enumerations | REFERENCE - ISO:C90-6.5.2.2 Enumeration Specifiers | ||||||
It should rarely be necessary to convert to an enum type. However, in this particular case, the value of a constant expression is being converted (either implicitly or explicitly) to an enumerated type when the value is not a valid member of the enumeration. Although the C language allows this operation it is almost certainly a dangerous error and should be rectified. Message 1317 is generated when the value of a constant expression is converted to an enum type and the value is not a member of the enumeration. However message 1461 will be generated instead if the value happens to be a value which can be generated from an inclusive bitwise inclusive OR (|) of some of the enumeration constants. For example:
/*PRQA S 2017,2211,2213,3120,3198,3199,3203,3408,3447,3602 ++*/
enum ET { RED, AMBER, GREEN };
extern void func1(enum ET p);
extern enum ET foo(void)
{
enum ET ena;
ena = 10; /* Message 1317 and 1412 */
ena = (enum ET)10; /* Message 1317 and 1484 */
func1(10); /* Message 1317 and 1411 */
return 10; /* Message 1317 and 1413 */
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |