Title
Unreachable enumeration list-initialization
Status
c++17
Section
9.4.5 [dcl.init.list]
Submitter
Richard Smith

Created on 2016-03-22.00:00:00 last changed 74 months ago

Messages

Date: 2016-12-15.00:00:00

Proposed resolution (December, 2016):

Reorder the bullets in 9.4.5 [dcl.init.list] paragraph 3 as follows:

List-initialization of an object or reference of type T is defined as follows:

  • ...

  • Otherwise, if T is a class type, constructors are considered...

  • Otherwise, if T is an enumeration with a fixed underlying type (9.7.1 [dcl.enum]), the initializer-list has a single element v, and the initialization is direct-list-initialization, the object is initialized with the value T(v) (7.6.1.4 [expr.type.conv]); if a narrowing conversion is required to convert v to the underlying type of T, the program is ill-formed. [Example:...

  • Otherwise, if the initializer list has a single element of type E...

  • Otherwise, if T is a reference type...

  • Otherwise, if T is an enumeration with a fixed underlying type...

Date: 2017-02-15.00:00:00

[Adopted at the February/March, 2017 meeting.]

P0138R2 adds a new bullet for enum initialization after bullet 8 of 9.4.5 [dcl.init.list] paragraph 3. However, paragraph 7 already dealt with all the cases where the initializer list contains a single element and the target type is a non-reference type, so the new paragraph 9 rule is unreachable.

History
Date User Action Args
2018-02-27 00:00:00adminsetstatus: review -> c++17
2017-02-06 00:00:00adminsetmessages: + msg5748
2016-03-22 00:00:00admincreate