This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15394] g++ fails to produce a static definition for static template member
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 May 2004 13:55:45 -0000
- Subject: [Bug c++/15394] g++ fails to produce a static definition for static template member
- References: <20040512134220.15394.razeh@yahoo.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bangerth at dealii dot org 2004-05-12 13:55 -------
No, Andrew, you are wrong again, but the code is invalid anyway. What
happens is that
template <> type Class<type>::member;
declares the existence of an explicit specialization of the member variable.
You can do that, there is no requirement that only the completely
unspecialized template class member variable can be declared. However, since
this syntax is the _declaration_ of a variable, not a _definition_, you get
a linker error. To make it a definition, you have to give the variable
declaration an initializer, i.e. do something like
template <> type Class<type>::member = 1;
or (if you want the default initialization):
template <> type Class<type>::member = type();
This will yield a _definition_ and should make the linker error go away.
Wolfgang
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15394