c++templatesvisual-c++visual-studio-2015visual-c++-2015

Error C1001: An internal error has occurred in the compiler


I have a virtual function inside a C++ templated task, and when it is compiled in Visual Studio 2015 (I have tried all combinations of Debug/Release and x86/x64), it consistently fails with compiler error C1001 on the following line of code:

e_Ty *d(new e_Ty[l]);

Where e_Ty is the template parameter of the class. This error only occurs when I use the template class with e_Ty set to std::pair<const int &, int &>. Is there a legitimate reason why this should not work, or is this a bug in MSVC?


EDIT

Notes:


Solution

  • An internal compiler error, an ICE, is always a bug.

    Please report it via Microsoft Connect.


    The code in question,

    e_Ty *d(new e_Ty[l]);
    

    may or may not be correct depending on l, whether appropriate headers have been included, and so on. There's too little context to say. is invalid for e_Ty as a std::pair of references, because references need to be initialized, as noted by T.C.. But that doesn't matter for an ICE.