This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See for the official list.


711. auto with braced-init-list

Section:  []     Status: CD2     Submitter: Jason Merrill     Date: 27 August, 2008

[Voted into WP at July, 2009 meeting.]

One effect of the initializer-list proposal is that now we allow

    auto x = { 1, 2, 3 };  // decltype(x) is std::initializer_list<int>

but not

    auto ar[3] = { 1, 2, 3 };  // ill-formed

This seems unfortunate, as the code for the first could also support the second. Incidentally, I also failed to update the text in [] paragraph 3 which forbids the use of auto with braced-init-lists, so technically the first form above is currently ill-formed but has defined semantics.

Bjarne Stroustrup:

Is this the thin edge of a wedge? How about

    vector<auto> v = { 1, 2, 3 };


    template<class T> void f(vector<T>& v);
    f({1, 2, 3 });

(See also issue 625.)

Proposed resolution (March, 2009):

Change [] paragraph 3 as follows:

...The decl-specifier-seq shall be followed by one or more init-declarators, each of which shall have a non-empty initializer. of either of the following forms:

[Drafting note: This change does not address the original issue of the inability to use auto with an array initializer, only the secondary issue of permitted the braced-init-list. The CWG explicitly decided not to support the array case.]