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


1222. Unnecessary restriction on auto array types

Section: 9.3.4.5  [dcl.array]     Status: NAD     Submitter: Michael Wong     Date: 2010-11-08

According to 9.3.4.5 [dcl.array] paragraph 1,

In a declaration T D where D has the form

and the type of the identifier in the declaration T D1 is “derived-declarator-type-list T”, then the type of the identifier of D is an array type; if the type of the identifier of D contains the auto type-specifier, the program is ill-formed.

This has the effect of prohibiting a declaration like

    int v[1];
    auto (*p)[1] = &v;

This restriction is unnecessary and presumably unintentional.

Note also that the statement that “the type of the identifier of D is an array type” is incorrect when the nested declarator is not simply a declarator-id. A similar problem exists in the wording of 9.4.4 [dcl.init.ref] paragraph 3 for function types.

Rationale (March, 2011):

The functionality of the auto specifier was intentionally restricted to simple cases; supporting complex declarators like this was explicitly discussed and rejected when the feature was adopted.