This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51604] New: [C++11][constexpr] Initializing static constexpr data members for class templates
- From: "zsol.zs.ol+gcc at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 17 Dec 2011 22:22:55 +0000
- Subject: [Bug c++/51604] New: [C++11][constexpr] Initializing static constexpr data members for class templates
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51604
Bug #: 51604
Summary: [C++11][constexpr] Initializing static constexpr data
members for class templates
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: zsol.zs.ol+gcc@gmail.com
Created attachment 26125
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26125
Example preprocessed source which exhibits above behavior
This code, when compiled with g++ -std=c++0x -c test.cpp
on: g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
template <typename T>
class X {
static constexpr unsigned char hello[];
};
template <typename T>
constexpr unsigned char X<T>::hello[] = {0, 1};
Gives the following error:
/home/zsol/test.cpp:3:38: error: constexpr static data member âhelloâ must have
an initializer
/home/zsol/test.cpp:7:37: error: redeclaration âX<T>::helloâ differs in
âconstexprâ
/home/zsol/test.cpp:3:38: error: from previous declaration âX<T>::helloâ
/home/zsol/test.cpp:7:37: error: âX<T>::helloâ declared âconstexprâ outside its
class
/home/zsol/test.cpp:7:37: error: declaration of âconst unsigned char
X<T>::hello []â outside of class is not definition [-fpermissive]
GCC 4.5 (g++-4.5 (Ubuntu/Linaro 4.5.3-9ubuntu1) 4.5.4) compiles this happily.