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


2319. Nested brace initialization from same type

Section:  []     Status: drafting     Submitter: Richard Smith     Date: 2016-09-06


  struct A { A(); } a;
  A a1 = {a}, a2 = {{a}}, a3 = {{{a}}};

a1 and a2 are valid, a3 is ill-formed, because [] bullet 4.5 allows one pair of braces and [over.ics.list] paragraph 2 allows a second pair of braces. The implicit conversion sequence from {{a}} to A is a user-defined conversion.

Prior to the list-initialization-from-same-type changes via issues 1467 and 2076, a2 was ill-formed like a3.

Is this intended, or did DR2076 not go far enough in reintroducing the restriction? Perhaps a more extreme rule, such as saying that a copy/move constructor is simply not a candidate for list-initialization from a list that contains one element that is itself a list, would work better?

Notes from the July, 2017 meeting:

CWG agreed that the a2 example should be ill-formed but that the a1 example must remain for C compatibility.