CWG Issue 2272 (original) (raw)

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

2025-04-13


2272. Implicit initialization of aggregate members of reference type

Section: 9.5.2 [dcl.init.aggr]Status: C++17Submitter: Vinny RomanoDate: 2016-06-10

[Adopted at the February/March, 2017 meeting.]

Consider:

struct S { const int &i; } s{};

This example ought to be ill-formed, but 9.5.2 [dcl.init.aggr] paragraph 8 states that i is instead initialized from an empty initializer list, which causes i to bind to a value-initialized temporary of type int.

Proposed resolution (February, 2017):

  1. Change 9.5.2 [dcl.init.aggr] paragraph 8 as follows:

If there are fewer _initializer-clause_s in the list than there are elements in the a non-union aggregate, then each element not explicitly initialized shall be initialized from its default member initializer (11.4 [class.mem]) or, if there is no default member initializer, from an empty initializer list (9.5.5 [dcl.init.list]). is initialized as follows:

If the aggregate is a union and the initializer list is empty, then

[Example:...

  1. Delete 9.5.2 [dcl.init.aggr] paragraph 11:

If an incomplete or empty initializer-list leaves a member of reference type uninitialized, the program is ill-formed.

This resolution also resolves issues 1622and 2116.