Date
2022-09-25.18:08:42
Message id
2597

Content

According to 7.7 [expr.const] paragraph 3,

A constant expression is an integral constant expression if it is of integral or enumeration type. [Note: such expressions may be used as array bounds (9.3.4.5 [dcl.array], 7.6.2.8 [expr.new]), as case expressions (8.5.3 [stmt.switch]), as bit-field lengths (11.4.10 [class.bit]), as enumerator initializers (9.8.1 [dcl.enum]), and as integral or enumeration non-type template arguments (13.4 [temp.arg]). —end note]

Although there is conceptually a conversion from enumeration type to integral type involved in using an enumerator as an array bound or bit-field length, the normative wording for those uses does not explicitly mention it and simply requires an integral constant expression. Consequently, the current wording permits uses like the following:

    enum class E { e = 10; };
    struct S {
        int arr[E::e];
        int i: E::e;
    };

This seems surprising.