This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-19
[Voted into the WP at the February, 2012 meeting; moved to DR at the October, 2012 meeting.]
One might expect that in an example like
int i; int & ir{i};
ir would bind directly to i. However, according to 9.4.5 [dcl.init.list] paragraph 3, this example creates a temporary of type int and binds the reference to that temporary:
...
Otherwise, if T is a reference type, a prvalue temporary of the type referenced by T is list-initialized, and the reference is bound to that temporary...
Otherwise, if the initializer list has a single element, the object or reference is initialized from that element...
Also, the “or reference” in the last bullet is dead code, as a reference initialization is always handled by the preceding bullet.
Proposed resolution (August, 2011):
Change 9.4.5 [dcl.init.list] paragraph 3 as follows:
...
Otherwise, if T is a class type, constructors are considered...
Otherwise, if T is a reference type, a prvalue
temporary of the type referenced by T is list-initialized,
and the reference is bound to that temporary. [Note: As usual,
the binding will fail and the program is ill-formed if the reference
type is an lvalue reference to a non-const type. —end
note] [Example: ... —end
example]
Otherwise, if the initializer list has a single element of type E and either T is not a reference type or its referenced type is reference-related to E, the object or reference is initialized from that element; if a narrowing conversion (see below) is required to convert the element to T, the program is ill-formed. [Example:...
Otherwise, if T is a reference type, a prvalue temporary of the type referenced by T is list-initialized, and the reference is bound to that temporary. [Note: As usual, the binding will fail and the program is ill-formed if the reference type is an lvalue reference to a non-const type. —end note] [Example: ... —end example]
Otherwise, if the initializer list has no elements...
...