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?
Notes:
l
is a local variable that was declared (and assigned a value as a result of a function call) ahead of time.auto
, and using assignment-style initialization, none of which worked.e_Ty
is int
.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 is invalid for l
, whether appropriate headers have been included, and so on. There's too little context to say.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.