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

2024-04-18


2359. Unintended copy initialization with designated initializers

Section: 9.4.2  [dcl.init.aggr]     Status: CD5     Submitter: Zhihao Yuan     Date: 2017-10-06

[Accepted at the June, 2018 (Rapperswil) meeting.]

According to 9.4.2 [dcl.init.aggr] bullet 4.2,

Otherwise, the element is copy-initialized from the corresponding initializer-clause or the brace-or-equal-initializer of the corresponding designated-initializer-clause.

This sounds as if the initialization performed by a designated initializer is always copy-initialization. However, it was intended that the kind of initialization match the form of the initializer, i.e., a designated-initializer-clause of the form

  { .x{3} }

was intended to perform direct-initialization.

Proposed resolution, April, 2018:

Change 9.4.2 [dcl.init.aggr] bullet 4.2 as follows:

Otherwise, the element is copy-initialized from the corresponding initializer-clause or is initialized with the brace-or-equal-initializer of the corresponding designated-initializer-clause.