Title
Misplaced list-initialization example
Status
cd2
Section
9.4.5 [dcl.init.list]
Submitter
Daniel Krügler

Created on 2009-10-20.00:00:00 last changed 178 months ago

Messages

Date: 2010-03-15.00:00:00

[Voted into WP at March, 2010 meeting.]

Date: 2009-10-15.00:00:00

Proposed resolution (October, 2009):

Move the S2 example from bullet 3 to bullet 1 in 9.4.5 [dcl.init.list] paragraph 3:

  • If T is an aggregate, aggregate initialization is performed (9.4.2 [dcl.init.aggr]).

    [Example:

      double ad[] = { 1, 2.0 };   // OK
      int ai[] = { 1, 2.0 };      // error: narrowing
    
      struct S2 {
        int m1;
        double m2,m3;
      };
      S2 s21 = { 1, 2, 3.0 };     // OK
      S2 s22 { 1.0, 2, 3 };       // error: narrowing
      S2 s23 {};                  // OK: default to 0,0,0
    

    end example]

  • Otherwise, if T is a specialization...

  • Otherwise, if T is a class type...

    [Example:

      ...
      S s3 { };                   // OK: invoke #2
    
      struct S2 {
        int m1;
        double m2,m3;
      };
      S2 s21 = { 1, 2, 3.0 };     // OK
      S2 s22 { 1.0, 2, 3 };       // error: narrowing
      S2 s23 {};                  // OK: default to 0,0,0
    

    end example]

  • ...

Date: 2022-02-18.07:47:23

The final set of declarations in the example following 9.4.5 [dcl.init.list] bullet 3.3 is:

    struct S2 {
      int m1;
      double m2,m3;
    };
    S2 s21 = { 1, 2, 3.0 };    // OK
    S2 s22 { 1.0, 2, 3 };      // error: narrowing
    S2 s23 {};                 // OK: default to 0,0,0

However, S2 is an aggregate. Aggregates are handled in bullet 1, while bullet 3 deals with classes with constructors. This part of the example should be moved to the first bullet.

History
Date User Action Args
2010-03-29 00:00:00adminsetmessages: + msg2713
2010-03-29 00:00:00adminsetstatus: ready -> cd2
2009-11-08 00:00:00adminsetmessages: + msg2364
2009-10-20 00:00:00admincreate