Compiler Bug in Visual C++ 10.0 SP1 - cl.exe version 16.0.40219.1 Access violation [confirmed]

StackOverflow https://stackoverflow.com/questions/18765097

  •  28-06-2022
  •  | 
  •  

Domanda

I have ran into a problem compiling some template code with Visual Stuido 2010 SP1, cl.exe version 16.0.40219.1

The following code will cause the compiler to access violate:

template<typename T>
class A
{
    A(){}
};

template<typename T>
class B : public A<T>
{
    using A::A(); // Compiler access violates
    // **EDIT**
    //using A<T>::A<T>; // Compiler succeeds
    //using A<T>::A(); // Compiler reports error
};

int main(int argc, char* argv[])
{
    return 0;
}

It generates the following error (in addition to the "cl.exe has stopped working, C0000005 exception):

1>d:\projects\cpptest\cpptest\cpptest.cpp(11): fatal error C1001: An internal error has occurred in the compiler.
1>  (compiler file 'msc1.cpp', line 1420)
1>   To work around this problem, try simplifying or changing the program near the locations listed above.

The code compiles fine (well, that is, it emits a proper error message and doesn't crash the compiler) in Dev-C++ with g++.

main.cpp:11: error: `template<class T> class A' used without template parameters
main.cpp:11: error: expected nested-name-specifier before "A"
main.cpp:11: error: using-declaration for non-member at class scope
main.cpp:11: error: expected `;' before '(' token
main.cpp:11: error: expected unqualified-id before ')' token
make.exe: *** [main.o] Error 1

EDIT The following, however, compiles fine, without access violation, so it seems this is related to templates:

class A
{
    A(){}
};

class B : public A
{
    using A::A;
};

int main(int argc, char* argv[])
{
    return 0;
}

Do you think this is worth reporting to Microsoft? Can anyone else reproduce this? Maybe try in Visual Studio 2013 to see if it still occurs?

È stato utile?

Soluzione

Since this is reproducible by others on Visual C++ platforms, I have opened a bug report on Microsoft Connect as "answer".

Also, as workaround, the following syntax works:

using A<T>::A<T>;

Altri suggerimenti

Update 2013-12-06: Microsoft has confirmed the issue and the issue will be fixed in the Visual Studio 2013 C++ compiler.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top