This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51604] [C++11][constexpr] Initializing static constexpr data members for class templates
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 17 Dec 2011 23:49:07 +0000
- Subject: [Bug c++/51604] [C++11][constexpr] Initializing static constexpr data members for class templates
- Auto-submitted: auto-generated
- References: <bug-51604-4@http.gcc.gnu.org/bugzilla/>
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.