Why do scoped enums allow use of | operator when initializing using previously assigned values?

[dcl.enum]/5:

... If the underlying type is fixed, the type of each enumerator prior to the closing brace is the underlying type ...

That is, each enumerator has type int until the closing brace is encountered. After that point, the enumerators have type FileCopy and you would not be able to bitwise-OR them together like this anymore.


According to the C++17 Standard (8.5.13 Bitwise inclusive OR operator)

1 The usual arithmetic conversions (8.3) are performed; the result is the bitwise inclusive OR function of its operands. The operator applies only to integral or unscoped enumeration operands.

And (10.2 Enumeration declarations)

  1. ... For a scoped enumeration type, the underlying type is int if it is not explicitly specified. In both of these cases, the underlying type is said to be fixed. Following the closing brace of an enum-specifier, each enumerator has the type of its enumeration. If the underlying type is fixed, the type of each enumerator prior to the closing brace is the underlying type and the constant-expression in the enumerator-definition shall be a converted constant expression of the underlying type

So this is explicitly documented behavior.