Bug: specialization of static member variables not supported ion VC7.1

A

Arne Adams

Hi,
the following does not compile with VC7.1 (and I think it should according to
the C++ Standard (1998))

template<class T> struct SpecializeStaticMember
{
static int m_Num;
};

// declaration and definition of the general member variable
// (will be 0 initialized because it has static storage duration)
template<class T> int SpecializeStaticMember<T>::m_Num;

// declaration of the special member variable must be visible before
// SpecializeStaticMember<double>::m_Num gets used
template<> int SpecializeStaticMember<double>::m_Num;

// definition of the special member variable must be in
// one and only one translation unit
template<> int SpecializeStaticMember<double>::m_Num = 23.1; /* error C2086
here*/
 
T

Tomas Restrepo \(MVP\)

Hi Arne,
Hi,
the following does not compile with VC7.1 (and I think it should according to
the C++ Standard (1998))

template<class T> struct SpecializeStaticMember
{
static int m_Num;
};

// declaration and definition of the general member variable
// (will be 0 initialized because it has static storage duration)
template<class T> int SpecializeStaticMember<T>::m_Num;

// declaration of the special member variable must be visible before
// SpecializeStaticMember<double>::m_Num gets used
template<> int SpecializeStaticMember<double>::m_Num;

// definition of the special member variable must be in
// one and only one translation unit
template<> int SpecializeStaticMember<double>::m_Num = 23.1; /* error C2086
here*/

Whidbey gives the same error. Comeau seems to agree with you that it should
work.
I'll but it against whidbey just in case.
 
T

Tian Min Huang

Hello Arne,

Thanks for your post. Tomas is correct and I am able to reproduce the
problem in Whidbey. The issue has been entered into our database and it is
being investigated. It is possible that this may be resolved in the next
version of VS .NET, but I cannot guarantee a resolution of this issue at
this time.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top