This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/51604] [C++11][constexpr] Initializing static constexpr data members for class templates


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51604

Daniel KrÃgler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #1 from Daniel KrÃgler <daniel.kruegler at googlemail dot com> 2011-12-17 23:49:07 UTC ---
This looks like an invalid issue to me. According to [class.static.data] p3:

"[..] 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 ] The
member shall still be defined in a namespace scope if it is odr-used (3.2) in
the program and the namespace scope definition shall not contain an
initializer."

which means the program should be rejected. The 4.7 head also rejects the code
as required by the standard.

Rewriting the code it to:

template <typename T>
class X {
  static constexpr unsigned char hello[] = {0, 1};
};

should solve the problem.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]