This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14132] static template member definition fails
- From: "guillaume dot melquiond at ens-lyon dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Feb 2004 21:42:51 -0000
- Subject: [Bug c++/14132] static template member definition fails
- References: <20040212191734.14132.guillaume.melquiond@ens-lyon.fr>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From guillaume dot melquiond at ens-lyon dot fr 2004-02-12 21:42 -------
Thanks, your reply has shown me what the correct solution is. Your solution is
not enough when there is more than one .o file. Indeed, this "template<class T>
def" syntax only defines classes when GCC sees the static member being accessed
in the current translation unit. So when the old code looks like:
int A<void>::a;
it must be replaced by:
template class A<void>;
template<class T> int A<T>::a;
Since the compiler puts these variables in the "common" section, the linker
won't complain when there are duplicates (since "template<class T> def" will
unfortunately catch all uses of the static members).
Thanks.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14132