------- Comment #7 from dpovey at gmail dot com  2010-06-16 17:57 -------
The key thing here is that the value was initialized inside the class.  So
there is no way to syntactically disambiguate a definition and a declaration of
the  value outside the class  (because normally C++ uses the initialization to
tell that you are defining it, but if you initialized it inside the class then
it doesn't let you initialize it again outside the class).  For non-specialized
"declarations/definitions", if they're initialized inside the class C++ is
forced to treat the (declaration/definition) without initializer as a
definition (I guess because it's more important to be able to define it to
declare it).  I assumed that when you specialize it, C++ also treats this
syntax as a definition.  It's possible that I was wrong.  If so I think it's a
misfeature in the C++ standard.  But I really don't know how it's interpreting
it.  

Suppose you do:

template <class A> class C{
  int i = 1;
};
template<> int C<void*>::i;

Let's suppose it treats this as a declaration.  What is it declaring?  There is
no syntax available to *define* the value (because it looks the same as a
declaration).  Conceivably you could later override the class itself, e.g.:

template <> class C<int> {
    int i = 0;
};

But I don't know whether C++ would treat the declaration statement above as
somehow relating to this.


-- 


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

Reply via email to