Title
Missing initializer clauses in aggregate initialization
Status
c++11
Section
9.4.2 [dcl.init.aggr]
Submitter
Jason Merrill

Created on 2010-06-01.00:00:00 last changed 130 months ago

Messages

Date: 2010-11-15.00:00:00

[Voted into the WP at the November, 2010 meeting.]

Date: 2010-08-15.00:00:00

Proposed resolution (August, 2010):

  1. Delete 9.4.5 [dcl.init.list] bullet 3.2, includeing the example:

    • Otherwise, if the initializer list has no elements and T is an aggregate, each of the members of T is initialized from an empty initializer list. [Example:...
  2. Change 9.4.2 [dcl.init.aggr] paragraph 7 as follows:

  3. If there are fewer initializer-clauses in the list than there are members in the aggregate, then each member not explicitly initialized shall be value-initialized (9.4 [dcl.init]) initialized from an empty initializer list (9.4.5 [dcl.init.list]).
Date: 2010-06-01.00:00:00
Issue 990 added the following text to 9.4.5 [dcl.init.list] paragraph 3:
  • Otherwise, if the initializer list has no elements and T is an aggregate, each of the members of T is initialized from an empty initializer list. [Example:...

A better way to handle this would be to delete that bullet and change 9.4.2 [dcl.init.aggr] paragraph 7 as follows:

If there are fewer initializer-clauses in the list than there are members in the aggregate, then each member not explicitly initialized shall be value-initialized (9.4 [dcl.init]) initialized from an empty initializer list (9.4.5 [dcl.init.list]).

This makes { } less of a special case and makes the following example work:

    struct A {
       A(std::initializer_list<int>);
    };
    struct B {
       int i;
       A a;
    };
    B b = { 1 };
History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetstatus: dr -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3177
2010-11-29 00:00:00adminsetstatus: ready -> dr
2010-08-23 00:00:00adminsetmessages: + msg2785
2010-06-01 00:00:00admincreate