Issue2252

Title 2252. Enumeration list-initialization from the same type
Status review Section 11.6.4 [dcl.init.list]
Submitter Richard Smith

Created on 2016-03-22.00:00:00 by admin, last changed by admin.

Messages
msg6186 (view) Date: 2018-03-15.00:00:00

Notes from the March, 2018 meeting:

CWG disagreed that the existing wording requires such a conversion, only that if such a conversion is possble, it must not narrow. A formulation along the lines of “if that initialization involves a narrowing conversion to the underlying type of T...” was suggested to clarify the intent. This will be handled editorially, and the issue will be left in "review" status until the change has been verified.

msg5880 (view) Date: 2018-04-11.00:00:00

According to 11.6.4 [dcl.init.list] bullet 3.8,

Otherwise, if T is an enumeration with a fixed underlying type (10.2 [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) (8.2.3 [expr.type.conv]); if a narrowing conversion is required to convert v to the underlying type of T , the program is ill-formed.

This could be read as requiring that there be a conversion from v to the underlying type of T, leaving the status of an example like the following unclear:

  enum class E {}; 
  struct X { operator E(); }; 
  E{X()}; // ok? 
History
Date User Action Args
2018-04-11 00:00:00adminsetstatus: open -> review
2018-04-11 00:00:00adminsetmessages: + msg6186
2018-02-27 00:00:00adminsetsection: 8.6.4 [dcl.init.list] -> 11.6.4 [dcl.init.list]
2016-03-22 00:00:00admincreate