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


2397. auto specifier for pointers and references to arrays

Section:  [term.array.type]     Status: DRWP     Submitter: Hubert Tong     Date: 2019-02-04

[Accepted as a DR at the June, 2021 meeting.]

According to [term.array.type] 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 formulation forbids useful constructs like

  int a[3];
  auto (*p)[3] = &a;

(accepted by current implementations) and should be relaxed to accommodate such cases.

Notes from the February, 2019 meeting:

CWG agreed that the example should be accepted.

Notes from the May 25, 2021 teleconference:

It was observed that CWG rejected the same example as being "not a defect" in considering issue 1222. However, the use of auto has significantly expanded since that time and the prohibition of such declarations now seems inconsistent.

Proposed resolution, May, 2021:

  1. Change [term.array.type] paragraph 4 as follows:

  2. U is called the array element type; this type shall not be a placeholder type ( []), a reference type, a function type, an array of unknown bound, or cv void.
  3. Change [dcl.fct] paragraph 11 as follows:

  4. The return type shall be a non-array object type, a reference type, or cv void. [Note: An array of placeholder type is considered an array type. —end note]
  5. Change [] paragraph 2 as follows:

  6. A type T containing a placeholder type, and a corresponding initializer E, are determined as follows:

    T shall not be an array type. In the case of a return statement with no operand...