If you compile the following code: template<class T=int> class MyTraits { public: static const T kValue = 0; };
template<> const int MyTraits<int>::kValue; // define it. int main(){ const void * a = &(MyTraits<int>::kValue); } g++ will issue no warnings but give linking errors. The statement template<> const int MyTraits<int>::kValue; is in error: it is intended to be a definition of the variable but C++ does not allow specializations of definitions (thanks to pinksia for pointing this out). I really should have templated the definition. However, the statement I did enter can have no possible purpose and I believe a warning should be issued. It is possible that the statement could be meaningful for a non-const static member (I don't know C++ well enough to judge) but it is definitely not meaningful for a static member: thus I believe a warning is in order. -- Summary: specialization of static const class member declaration should issue warning. Product: gcc Version: 4.3.5 Status: UNCONFIRMED Severity: trivial Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dpovey at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44552