[Bug c++/52069] ARM: initialization of static member in template struct
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 31 16:00:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52069
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-31 15:47:40 UTC ---
The program is ill-formed:
"If a template, a member template or a member of a class template is explicitly
specialized then that specialization shall be declared before the first use of
that specialization that would cause an implicit instantiation to take place,
in every translation unit in which such a use occurs; no diagnostic is
required."
When compiling main.o the compiler has no way to know that you have explicitly
instantiated S<T>::id so it is implicitly instantiated.
You need to declare the explicit instantiation in tmpl.h
template<> struct ID S<T>::id;
That will prevent the implicit instantiation of that member in main.o, and your
explicit instantiation in libtmpl.so will be used.
More information about the Gcc-bugs
mailing list