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

2024-11-11


1095. List-initialization of references

Section: 9.4.5  [dcl.init.list]     Status: C++11     Submitter: Daniel Krügler     Date: 2010-07-26

[Voted into the WP at the March, 2011 meeting as part of paper N3262.]

The current wording of the WP appears not to allow for list-initialization of a reference like the following:

    int i;
    int& ir{i};

First, 9.4 [dcl.init] bullet 16.1 reads,

A reference is not an object, so this does not appear to apply; however, the second bullet sends reference initialization off to 9.4.4 [dcl.init.ref], which does not cover braced-init-lists: paragraph 5 of that section deals only with initilizer expressions, and a braced-init-list is not an expression.

Assuming that the use of “object” in the first bullet is just an oversight, 9.4.5 [dcl.init.list] also does not cover the case of a reference to a scalar type whose initalizer is a braced-init-list with a single element. Bullet 7 of paragraph 3 reads,

and would cover this case except that, again, a reference is not an object. As a result, such an initialization would end up in the last bullet and consequently be ill-formed.

Presumably all that is needed is to add “or reference” to the appropriate bullets of 9.4 [dcl.init] paragraph 16 and 9.4.5 [dcl.init.list] paragraph 3.

Proposed resolution (November, 2010) [SUPERSEDED]:

  1. Change 9.4 [dcl.init] bullet 16.1 as follows:

  2. Change 9.4.5 [dcl.init.list] bullet 3.7 as follows: