This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/588: defining static data member of template class needs initializer
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/588: defining static data member of template class needs initializer
- From: brianchon at sina dot com
- Date: 1 Oct 2000 17:03:33 -0000
- Reply-To: brianchon at sina dot com
- Resent-Cc: gcc-prs at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, jason at gcc dot gnu dot org
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, brianchon@sina.com
>Number: 588
>Category: c++
>Synopsis: defining static data member of template class needs initializer
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Sun Oct 01 10:06:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: brianchon@sina.com
>Release: unknown-1.0
>Organization:
>Environment:
cygwin, mingw32
>Description:
when using template specialization syntax to define a static data member of a class template, an initializer must be supplied, otherwise a "not defined" linkage error will occur.
>How-To-Repeat:
template<typename T>
class A {
public:
static T x;
T GetX() {return x;}
};
template<> int A<int>::x; // linkage error
//int A<int>::x; this one is OK
//template<> int A<int>::x = 0; is OK too.
int main()
{
A<int> a;
return a.GetX();
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: