$ cat file1.cc
#include <list>

template<typename T>
struct my_struct {
        typedef typename std::list<T*> list_t;
        static list_t list1;
        static list_t list2;
};

template<> my_struct<int>::list_t my_struct<int>::list1; //error
template<> my_struct<int>::list_t my_struct<int>::list2(0); //OK

int main() {
int i,j;
i = my_struct<int>::list1.size();
j = my_struct<int>::list2.size();
}

$ g++ file1.cc
/tmp/ccO1DNIw.o(.text+0x1f): In function `main':
: undefined reference to `my_struct<int>::list1'
collect2: ld returned 1 exit status
[EMAIL PROTECTED] gcc_3.4 $ g++ --version
g++ (GCC) 3.4.3 20050110 (Gentoo Linux 3.4.3.20050110, ssp-3.4.3.20050110-0,
pie-8.7.7)

-- 
           Summary: undefined reference to static member of template struct
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bin-krzysiek at poczta dot gazeta dot pl
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to