Re: static-const-integral in-class-init without explicit definition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>I think GCC has always supported it, because it's >valid C++. Do you
>have reason to believe otherwise?

C++ standard, ISO/IEC 14882: 2003 states,
" 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
(5.19). In that case, the member can appear in integral constant
expressions. 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."

So, though it is a static const integral, if used in the program, it
shall be defined is what the C++ standard says.
But, there is also a defect raised regd. this,
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#454.

But, C++11 states,
$9.4.2
"3. If a non-volatile const static data member is of integral or
enumeration type,it's declaration in the class definition can specify
a brace-or-equal-initialized in which every initializer-clause that is
an assignment expression is a constant expression(5.19).A static data
member of literal type can be declared in the class definition with
the constexpr specifier;if so,it's 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 expression.—endnote] The
member shall still be defined in a namespace scope if it is
odr-used(3.2)in the program and the name space scope definition shall
not contain an initializer."

My thoughts were, either wording is corrected in C++11 or C++11
started supporting it.

So, I thought of understanding , since when GCC started to supporting
it to get an idea.

Thanks

Raja Gopal M
smrajagopal [at] gmail [dot] com





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux