This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/22191] New: undefined reference to static member of template struct
- From: "bin-krzysiek at poczta dot gazeta dot pl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Jun 2005 14:10:23 -0000
- Subject: [Bug c++/22191] New: undefined reference to static member of template struct
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
$ 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
Krzysiek@puszka 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