This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/52069] ARM: initialization of static member in template struct


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]