[Bug c++/14132] static template member definition fails
guillaume dot melquiond at ens-lyon dot fr
gcc-bugzilla@gcc.gnu.org
Thu Feb 12 21:42:00 GMT 2004
------- 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
More information about the Gcc-bugs
mailing list