Created on 2013-07-31.00:00:00 last changed 8 months ago
Additional notes (March, 2024)
This paragraph has more issues and is largely redundant with 6.2 [basic.def] paragraph 2.3 and paragraph 2.4.
Possible resolution:
Change 11.4.9.3 [class.static.data] paragraph 4 as follows:
If a non-volatile non-inline const static data member is of 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]). The member shall still be defined in a namespace scope if it is odr-used (6.3 [basic.def.odr]) in the program and the namespace scope definition shall not contain an initializer . The declaration of an inline static data member (which is a definition) may specify a brace-or-equal-initializer . If the member is declared with the constexpr specifier, it may be redeclared in namespace scope with no initializer (this usage is deprecated; see D.5 [depr.static.constexpr]). Declarations of other static data members shall not specify a brace-or-equal-initializer.
A declaration of a static data member in a class definition shall not specify a brace-or-equal-initializer unless the member is either inline or of non-volatile const integral or enumeration type. In the latter case, the member shall be constant-initialized (7.7 [expr.const]).
Describing the handling of static data members with brace-or-equal-initializers, 11.4.9.3 [class.static.data] paragraph 4 says,
The member shall still be defined in a namespace scope if it is odr-used (6.3 [basic.def.odr]) in the program and the namespace scope definition shall not contain an initializer.
The word “shall” implies a required diagnostic, but this is describing an ODR violation (the static data member might be defined in a different translation unit) and thus should be “no diagnostic required.”
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-03-06 21:18:13 | admin | set | messages: + msg7633 |
2024-03-06 21:18:13 | admin | set | status: drafting -> review |
2013-10-14 00:00:00 | admin | set | status: open -> drafting |
2013-07-31 00:00:00 | admin | create |