Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Confusion over enum type expressions
#1
Hi,
The rationale for rule 7-2-1 states,
Quote:It is unspecified behaviour if the evaluation of an expression with enum underlying type yields a value which does not correspond to one of the enumerators of the enumeration.
This assertion contains a slight inaccuracy. The relevant section of the ISO C++ (2003) standard, 7.2(9), actually reads,
Quote:An expression of arithmetic or enumeration type can be converted to an enumeration type explicitly. The value is unchanged if it is in the range of enumeration values of the enumeration type; otherwise the resulting enumeration value is unspecified.
(emphasis added by this Poster).

Should the MISRA C++ rule, instead, read,
Quote:An expression with enum underlying type shall only have values within the range of the enumerators of the enumeration.
(emphasis, again, added by this Poster)?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)