[Bug c++/51604] New: [C++11][constexpr] Initializing static constexpr data members for class templates
zsol.zs.ol+gcc at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Dec 17 22:44:00 GMT 2011
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.
More information about the Gcc-bugs
mailing list