This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-10-26


2824. Copy-initialization of arrays

Section: 9.4.1  [dcl.init.general]     Status: DRWP     Submitter: Anoop Rana     Date: 2023-11-06

[Accepted as a DR at the March, 2024 meeting.]

Consider:

  std::string arr[] = "some string";

Prior to the application of paper P0960R3 (Allow initializing aggregates from a parenthesized list of values), this was ill-formed, but now it is well-formed. However, the specification talks about an expression-list as part of the initializer, which does not exist in this case.

Proposed resolution (approved by CWG 2023-11-07):

Change in 9.4.1 [dcl.init.general] bullet 16.5 as follows:

Otherwise, if the destination type is an array, the object is initialized as follows. The initializer shall be of the form ( expression-list ). Let x1 , . . . , xk be the elements of the expression-list. If the destination type is an array of unknown bound, it is defined as having k elements. Let n denote the array size after this potential adjustment. If k is greater than n, the program is ill-formed. Otherwise, ...