Title
Nested brace initialization from same type
Status
drafting
Section
12.2.4.2 [over.best.ics]
Submitter
Richard Smith

Created on 2016-09-06.00:00:00 last changed 25 months ago

Messages

Date: 2017-07-15.00:00:00

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.

Date: 2022-02-18.07:47:23

Consider:

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

a1 and a2 are valid, a3 is ill-formed, because 12.2.4.2 [over.best.ics] bullet 4.5 allows one pair of braces and 12.2.4.2.6 [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?

History
Date User Action Args
2022-02-18 07:47:23adminsetmessages: + msg6715
2016-09-06 00:00:00admincreate