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++/15394] g++ fails to produce a static definition for static template member


------- Additional Comments From bangerth at dealii dot org  2004-05-12 13:55 -------
No, Andrew, you are wrong again, but the code is invalid anyway. What 
happens is that 
 
  template <> type Class<type>::member; 
 
declares the existence of an explicit specialization of the member variable. 
You can do that, there is no requirement that only the completely 
unspecialized template class member variable can be declared. However, since 
this syntax is the _declaration_ of a variable, not a _definition_, you get 
a linker error. To make it a definition, you have to give the variable 
declaration an initializer, i.e. do something like 
   
  template <> type Class<type>::member = 1; 
 
or (if you want the default initialization): 
 
  template <> type Class<type>::member = type(); 
 
This will yield a _definition_ and should make the linker error go away. 
 
Wolfgang 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15394


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