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++/14132] static template member definition fails


------- 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


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