This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110c. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-02-07


1767. Scoped enumeration in a switch statement

Section: 8.5.3  [stmt.switch]     Status: C++14     Submitter: Canada     Date: 2013-09-23

N3690 comment CA 8

[Moved to DR at the February, 2014 meeting.]

The description of the switch statement and case labels in 8.5.3 [stmt.switch] paragraph 2 apply integral promotions to the condition value and refer to the “promoted type” of the condition. However, the integral promotions (7.3.7 [conv.prom]) do not describe the result when they are applied to a scoped enumeration value.

Proposed resolution (September, 2013):

Change 8.5.3 [stmt.switch] paragraph 2 as follows:

The condition shall be of integral type, enumeration type, or class type. If of class type, the condition is contextually implicitly converted (7.3 [conv]) to an integral or enumeration type. Integral promotions are performed. If the (possibly converted) type is subject to integral promotions (7.3.7 [conv.prom]), the condition is converted to the promoted type. Any statement within the switch statement can be labeled with one or more case labels as follows:

where the constant-expression shall be a converted constant expression (7.7 [expr.const]) of the promoted adjusted type of the switch condition. No two of the case constants in the same switch shall have the same value after conversion to the promoted type of the switch condition.