xmllmx
xmllmx

Reputation: 42215

VC++ compiler crashes when compiling a simplest piece of code

My compiler is VC++ 2013 and 2013 Novmember CTP.

The following code makes the VC++ compiler crash and report:

"fatal error C1001: An internal error has occurred in the compiler."

template<class T>
class A
{
    operator T*() const
    {
        return p;
    }

    T* p;
};

template<class T>
class B : public A<T>
{
    using A::operator T*;
};

int main()
{}

Upvotes: 0

Views: 109

Answers (1)

gx_
gx_

Reputation: 4760

There's probably a bug in the VC++ compiler, but your code is still incorrect: g++ reports error: 'template<class T> class A' used without template parameters (link). (That's often a good idea to test code on different compilers.)

Change line 15 from

    using A::operator T*;

to

    using A<T>::operator T*;

(i.e. change “A” to “A<T>”).

Upvotes: 5

Related Questions