This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-12-20
[Voted into the WP at the March, 2011 meeting.]
According to 9.8.1 [dcl.enum] paragraph 10,
An expression of arithmetic or enumeration type can beconverted to an enumeration type explicitly.
However, 7.6.1.9 [expr.static.cast] paragraph 10 says only,
A value of integral or enumeration type can be explicitlyconverted to an enumeration type.
This omits floating-point values. Presumably unscopedenumeration types are covered by paragraph 7,
The inverse of any standard conversion sequence (7.3 [conv]), other than the lvalue-to-rvalue(7.3.2 [conv.lval]), array-to- pointer (7.3.3 [conv.array]), function-to-pointer (7.3.4 [conv.func]), and boolean (7.3.14 [conv.fctptr])conversions, can be performed explicitly usingstatic_cast.
because 7.3.11 [conv.fpint] paragraph 2 allows anunscoped enumeration value to be implicitly converted to afloating point type. (Although that also covers the integraltypes, so it's not clear why they would be mentionedspecifically in 7.6.1.9 [expr.static.cast] paragraph 10.)However, this should presumably say “arithmetic”instead of “integral” to match the statement in9.8.1 [dcl.enum] paragraph 10.
Proposed resolution (November, 2010):
Change 7.6.1.9 [expr.static.cast] paragraph 10 as follows:
A value of integral or enumeration type can be explicitly converted toan enumeration type. The value is unchanged if the original value iswithin the range of the enumeration values (9.8.1 [dcl.enum]). Otherwise, the resultingenumerationvalue isunspecified(and might not be in that range). A value offloating-point type can also be converted to an enumeration type. Theresulting value is the same as converting the original value to theunderlying type of the enumeration (7.3.11 [conv.fpint]), andsubsequently to the enumeration type.
Add the following footnote to the end of 9.8.1 [dcl.enum] paragraph 7:
...If theenumerator-list is empty, the values of theenumeration are as if the enumeration had a single enumerator withvalue 0.[Footnote: This set of values is used to definepromotion and conversion semantics for the enumeration type; it doesnot exclude an expression of enumeration type from having a value thatfalls outside this range. —end footnote]
Delete 9.8.1 [dcl.enum] paragraph 10:
An expression of arithmetic or enumeration type can be convertedto an enumeration type explicitly. The value is unchanged if it is inthe range of enumeration values of the enumeration type; otherwise theresulting enumeration value is unspecified.