This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12222] explicit initialization of static template members seems ignored
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Aug 2004 18:37:26 -0000
- Subject: [Bug c++/12222] explicit initialization of static template members seems ignored
- References: <20030909101558.12222.stefaandr@hotmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bangerth at dealii dot org 2004-08-16 18:37 -------
gcc's behavior actually makes a lot more sense than anyone seems to
have noticed: with this code
----------------
template <typename T>
struct a { static int b1; };
template struct a<float>;
template <> int a<float>::b1;
int x = a<float>::b1;
-----------------
we indeed get no warning that a specialization is declared after
instantiating the template. However, that's about ok: we haven't
provided a definition of the static member, so it isn't instantiated
and the declaration of the specialization doesn't come too late.
On the other hand, for this code (not the presence of the definition)
------------------
template <typename T>
struct a { static int b1; };
template <typename T> int a<T>::b1;
template struct a<float>;
template <> int a<float>::b1;
int x = a<float>::b1;
------------------
we _do_ get an error:
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -Wall -c x.cc
x.cc:6: error: redefinition of `int a<float>::b1'
x.cc:3: error: `int a<float>::b1' previously declared here
I think gcc is correct here. So closing.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12222