This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 108h. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2022-07-01


2099. Inferring the bound of an array static data member

Section: 9.3.4.5  [dcl.array]     Status: CD4     Submitter: Richard Smith     Date: 2015-03-15

[Adopted at the February, 2016 meeting.]

According to 9.3.4.5 [dcl.array] paragraph 3,

An array bound may also be omitted when the declarator is followed by an initializer (9.4 [dcl.init]). In this case the bound is calculated from the number of initial elements...

However, the grammar for member-declarator uses brace-or-equal-initializer, not initializer, so the following is ill-formed:

  struct X {
    static constexpr int arr[] = { 1, 2, 3 };
  };

Proposed resolution (October, 2015):

Change 9.3.4.5 [dcl.array] paragraph 3 as follows:

...An array bound may also be omitted when the declarator is followed by an initializer (9.4 [dcl.init]) or when a declarator for a static data member is followed by a brace-or-equal-initializer (11.4 [class.mem]). In this case both cases the bound is calculated from the number of initial elements...