[Bug c++/31044] Compilation fails on definition of a static template class member

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Fri Mar 9 05:01:00 GMT 2007



------- Comment #1 from bangerth at dealii dot org  2007-03-09 05:01 -------
Confirmed, though I believe this is a duplicate of some other PR. This
is not a regression.

Somewhat smaller:
--------------
template<int i> class C {};

template<class T>
class X
{
        static const unsigned int Value = 2;
        static const C<Value> m_X;
};

template<class T>
const C<X<T>::Value> X<T>::m_X;
--------------------

g/x> c++ -c x.cc
x.cc:11: error: conflicting declaration 'const C<X<T>::Value> X<T>::m_X'
x.cc:7: error: 'X<T>::m_X' has a previous declaration as 'const C<2> X<T>::m_X'
x.cc:11: error: declaration of 'const C<2> X<T>::m_X' outside of class is not
definition

The last error happens because the last line of code is indeed not a
definition.
To avoid it, one would need to specify an initializer.

W.


-- 

bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at dealii dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |rejects-valid
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-09 05:01:26
               date|                            |


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



More information about the Gcc-bugs mailing list