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

2024-04-18


1101. Non-integral initialized static data members

Section: 11.4.9.3  [class.static.data]     Status: C++11     Submitter: Jason Merrill     Date: 2010-08-02

[Voted into the WP at the March, 2011 meeting as part of paper N3262.]

According to 11.4.9.3 [class.static.data] paragraph 3,

If a static data member is of const literal type, its declaration in the class definition can specify a brace-or-equal-initializer in which every initializer-clause that is an assignment-expression is a constant expression. A static data member of literal type can be declared in the class definition with the constexpr specifier; if so, its declaration shall specify a brace-or-equal-initializer in which every initializer-clause that is an assignment-expression is a constant expression. [Note: In both these cases, the member may appear in constant expressions. —end note]

However, 7.7 [expr.const] bullet 2.7 allows only integral and enumeration types in constant expressions for the const case; the other types require constexpr to be considered constant expressions.

Proposed resolution (November, 2010):

Change 11.4.9.3 [class.static.data] paragraph 3 as follows:

If a non-volatile const static data member is of const literal integral or enumeration type, its declaration in the class definition can specify a brace-or-equal-initializer in which every initializer-clause that is an assignment-expression is a constant expression (7.7 [expr.const]). A static data member of literal type can be declared in the class definition with the constexpr specifier...