2823. std::array initialization is still not permissive enough

Section: 26.3.7.1 [array.overview] Status: New Submitter: Robert Haberlach Opened: 2016-11-16 Last modified: 2017-02-02

Priority: 2

View other active issues in [array.overview].

View all other issues in [array.overview].

View all issues with New status.

Discussion:

LWG 2590's resolution is incomplete:

std::array<int, 1> arr{{0}};

should be fine, but isn't guaranteed, since {0} has no type. We should rather go for implicit conversion:

An array is an aggregate (11.6.1 [dcl.init.aggr]) that can be list-initialized with up to N elements whose types are convertible to Tthat can be implicitly converted to T.

[2016-11-26, Tim Song comments]

This is not possible as written, because due to the brace elision rules for aggregate initialization, std::array<int, 2> arr{{0}, {1}}; will never work: the {0} is taken as initializing the inner array, and the {1} causes an error.

[2017-01-27 Telecon]

Priority 2; consensus is that the P/R is not quite right.

Proposed resolution:

This wording is relative to N4606.

  1. Change 26.3.7.1 [array.overview] p2 as indicated:

    -2- An array is an aggregate (11.6.1 [dcl.init.aggr]) that can be list-initialized with up to N elements whose types are convertiblethat can be implicitly converted to T.