Title
Unnecessary restriction on auto array types
Status
nad
Section
9.3.4.5 [dcl.array]
Submitter
Michael Wong

Created on 2010-11-08.00:00:00 last changed 158 months ago

Messages

Date: 2011-03-15.00:00:00

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.

Date: 2022-11-20.07:54:16

According to 9.3.4.5 [dcl.array] paragraph 1,

In a declaration T D where D has the form

    D1 [ constant-expressionopt ] attribute-specifieropt

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.

History
Date User Action Args
2011-04-10 00:00:00adminsetmessages: + msg3412
2011-04-10 00:00:00adminsetstatus: open -> nad
2010-11-08 00:00:00admincreate