This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112e. See for the official list.


2768. Assignment to enumeration variable with a braced-init-list

Section: 7.6.19  [expr.ass]     Status: ready     Submitter: Shafik Yaghmour     Date: 2023-07-06


   enum class E {E1};

   void f() {
     E e;
     e = E{0}; // #1
     e = {0};  // #2

#1 first initializes a temporary of type E and then assigns that to e. For #2, 7.6.19 [expr.ass] bullet 8.1 specifies that #2 is equivalent to #1:

A braced-init-list may appear on the right-hand side of

However, there is no syntactic hint that #2 would invoke direct-initialization, and in fact gcc, icc, and MSVC reject #2, but clang accepts.

Proposed resolution (approved by CWG 2023-11-06):

Change in 7.6.19 [expr.ass] paragraph 8 as follows:

A braced-init-list B may appear on the right-hand side of