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

2024-12-19


714. Static const data members and braced-init-lists

Section: 11.4.9.3  [class.static.data]     Status: CD2     Submitter: Steve Adamczyk     Date: 15 September, 2008

[Voted into WP at July, 2009 meeting.]

The recent changes in the handling of initialization have not touched the requirement that the in-class initializer for a const static data member must be of the form = assignment-expression and not a braced-init-list. It would be more consistent and general to allow the braced form as well.

Proposed resolution (March, 2009):

  1. Change 7.7 [expr.const] paragraph 3 as follows:

  2. ...as enumerator initializers (9.7.1 [dcl.enum]), as static member initializers (11.4.9.3 [class.static.data]), and as integral or enumeration non-type template arguments (13.6 [temp.type]).
  3. Change 11.4.9.3 [class.static.data] paragraph 3 as follows:

  4. If a static data member is of const effective literal type, its declaration in the class definition can specify a brace-or-equal-initializer with an in which every initializer-clause that is an assignment-expression is a integral constant expression. A static data member of effective literal type can be declared in the class definition with the constexpr specifier; if so, its declaration shall specify a brace-or-equal-initializer with an in which every initializer-clause that is an assignment-expression is a integral constant expression. [Note: In both these cases, the member may appear in integral constant expressions. end note] The member shall still be defined in a namespace scope if it is used in the program and the namespace scope definition shall not contain an initializer.

[Drafting note: this change also corrects an editorial error resulting from overlapping changes that inadvertently retained the original restriction that only members of integral type could be initialized inside the class definition.]