W
wkaras
Section 9.4.2 paragraph 4 of the draft Standard 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 (expr.const)
In that case, the member can appear in integral constant expressions
within its scope. 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.
It sounds like the last sentance is saying that the definition in
"namespace" scope is still always necessary. Yet GCC compiles
and links this just fine:
#include "stdio.h"
class A { public: static const int I = 10; };
int main(void) { printf("%d\n", A::I); return(0); }
Assembler output shows GCC never reserves space in memory for I .
Is GCC non-compliant here for not pointlessly outputting an error
for the lack of a definition (of I) that would only cause a
waste of memory? Or was this changed in the final standard? Or,
am I just interpreting the standard wrong?
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 (expr.const)
In that case, the member can appear in integral constant expressions
within its scope. 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.
It sounds like the last sentance is saying that the definition in
"namespace" scope is still always necessary. Yet GCC compiles
and links this just fine:
#include "stdio.h"
class A { public: static const int I = 10; };
int main(void) { printf("%d\n", A::I); return(0); }
Assembler output shows GCC never reserves space in memory for I .
Is GCC non-compliant here for not pointlessly outputting an error
for the lack of a definition (of I) that would only cause a
waste of memory? Or was this changed in the final standard? Or,
am I just interpreting the standard wrong?