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

2024-03-20


75. In-class initialized members must be const

Section: 11.4  [class.mem]     Status: TC1     Submitter: John Wiegley     Date: 29 Dec 1998

The standard says, in 11.4 [class.mem] paragraph 4:

A member-declarator can contain a constant-initializer only if it declares a static member (11.4.9 [class.static] ) of integral or enumeration type, see 11.4.9.3 [class.static.data] .
But later, in the section on static class data member initialization, 11.4.9.3 [class.static.data] paragraph 4, it says:
If a static data member is of const integral or const enumeration type, its declaration in the class definition can specify a constant-initializer which shall be an integral constant expression (7.7 [expr.const] ). In that case, the member can appear in integral constant expressions within its scope.
The first paragraph should be modified to make it clear that it is not possible to initialize a static data member in-line with a constant-initializer if that data member is of integral (or enumeration) type, and yet not const.

Proposed Resolution (10/99): Change the sentence in 11.4 [class.mem] paragraph 4 to read:

A member-declarator can contain a constant-initializer only if it declares a static member (11.4.9 [class.static] ) of const integral or const enumeration type, see 11.4.9.3 [class.static.data] .