Affected subclause: [expr.arith.conv]
Change: The usual arithmetic conversions differ, between C and C++,
in the treatment of enumeration types with no fixed underlying type
. In C++, values of such types are not specified
as converting to the underlying type of the enumeration
as part of the usual arithmetic conversions
. Rationale: Avoids the difference that can arise in C
when replacing an enumeration constant in
an expression with a cast of the same enumeration constant
to the enumeration type
. Allows C++ to treat an enumerator with behavior
like that of
int
even while giving the enumerator the type of its enumeration
. Effect on original feature: Changes to semantics of well-defined feature
. Some C expressions that have a dependence upon
the implementation-defined
underlying type of affected enumeration types
will yield different results
(as they would if a different underlying type
is chosen by the C implementation)
. [
Example 5:
typedef enum { E0 } E;
static_assert(((E)E0 - 1 < 0) == (E0 - 1 < 0), "Must pass for C++");
The
static_assert may fail in C
. —
end example]
Difficulty of converting: Programs must add explicit casts to the underlying type
.