Compiling:
template<class T>
class A
{
public:
   static const unsigned int n = 1;

   void foo ()
   {
      int i = n;
   }
};

extern template class A<int>;

int main ()
{
   A<int> a;
   a.foo ();
}

fails with:
foo.cpp: In member function 'void A<T>::foo() [with T = int]':
foo.cpp:9:   instantiated from 'const unsigned int A<int>::n'
foo.cpp:9:   instantiated from 'void A<T>::foo() [with T = int]'
foo.cpp:18:   instantiated from here
foo.cpp:9: error: explicit instantiation of 'A<int>::n' but no definition
available
foo.cpp:9:   instantiated from 'const unsigned int A<int>::n'
foo.cpp:9:   instantiated from 'void A<T>::foo() [with T = int]'
foo.cpp:18:   instantiated from here
foo.cpp:9: error: explicit instantiation of 'A<int>::n' but no definition
available


-- 
           Summary: Forward explicit intantiation declaration doesn't mix
                    well with static integral member
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nicos at maunakeatech dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to