Question

Niels Dekker on Thu, 15 Jan 2015 16:41:00


Visual C++ 2013 Update 4 (Release configuration, x64 platform) appears to crash on the following simple code:

int main()
{
  double myArray[3] = {};
  for (int i = 0; i < 2; ++i)
    myArray[i] = 2.0 * myArray[static_cast<short>(i+1)];
}

As can be reproduced by doing cl Source.cpp /O2 at the "VS2013 x64 Native Tools Command Prompt":

G:\>cl Source.cpp /O2
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

Source.cpp
g:\source.cpp(4) : fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 228)
 To work around this problem, try simplifying or changing the program near the locations listed above.
Please choose the Technical Support command on the Visual C++
 Help menu, or open the Technical Support help file for more information
INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\cl.exe'
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information

The internal compiler error appears triggered by the narrowing conversion, static_cast<short>. We encountered such an internal compiler error with other narrowing integer conversions as well, for example from 'long long' to 'long', or from 'long' to 'short'. And also when those conversions were implicit (without explicit static_cast). However, it only occurs in "certain situations" (for-loop, array iteration). Is this a known issue?


Sponsored



Replies

Yan Avlasov on Thu, 15 Jan 2015 16:52:30


File a bug.

Niels Dekker on Thu, 15 Jan 2015 21:43:11


Thanks, Yan, but I would like to get some more information about this internal compiler error, before submitting a bug report. It seems that the bug was introduced with Visual C++ 2013. I cannot reproduce it in Visual Studio 2012. However, a Visual C++ 2013 compiler without any updates (Compiler Version 18.00.21005.1 for x64) already has the bug. And it's still there in VS2013 Update 4!

Here's another example:

long long Get(const long long* ptr, unsigned i) {
  return ptr[i];
}

int main() {
  long long myArray[2] = {};
  size_t i = 0;
  while(++i <= 2) 
    myArray[i - 1] = Get(myArray, i - 1) + 1;
}

In this case, the implicit conversion from 'size_t' (64 bits) to 'unsigned' (32 bits), when passing the second parameter to the 'Get' function, appears to trigger the internal compiler error.

Has no one else encountered this issue of the 64-bits (x64) version of Visual C++ 2013 before?  


Pavel A on Thu, 15 Jan 2015 22:03:27


Have you tested on Update 5 CTP? It would be a good opportunity to request a fix.

Niels Dekker on Thu, 15 Jan 2015 22:25:29


Pavel A wrote:

Have you tested on Update 5 CTP? It would be a good opportunity to request a fix.

Thanks, Pavel. I haven't installed VS2013 Update 5 CTP. If you or anyone else here has installed Update 5 CTP, please tell me if my examples compile (x64, "/O2") on your installation!

However, would Update 5 have any compiler bug fixes at all? KB 3021976 Description of Visual Studio 2013 Update 5 CTP 1 does not mention any.

David Lowndes on Fri, 16 Jan 2015 09:44:52


>It seems that the bug was introduced with Visual C++ 2013. I cannot reproduce it in Visual Studio 2012. However, a Visual C++ 2013 compiler without any updates (Compiler Version 18.00.21005.1 for x64) already has the bug. And it's still there in VS2013 Update 4!

It seems to be OK with the VC++ 2015 Preview compiler too.

Dave

Niels Dekker on Mon, 19 Jan 2015 16:18:54


Please check the bug report I just submitted on this issue:

[C/C++] VS2013 x64 Release (/O2) fatal error C1001 on narrowing integer conversions during array iteration: internal compiler error (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 228)

http://connect.microsoft.com/VisualStudio/feedbackdetail/view/1093610

Please consider voting, or indicating that you can reproduce the internal compiler error.

Niels Dekker on Sat, 24 Jan 2015 18:10:12


Please check the bug report I just submitted on this issue:

[C/C++] VS2013 x64 Release (/O2) fatal error C1001 on narrowing integer conversions during array iteration: internal compiler error (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 228)

http://connect.microsoft.com/VisualStudio/feedbackdetail/view/1093610

It seems like the bug (internal compiler error) won't be fixed with any Visual Studio 2013 update.  :-(  The bug report was closed by Microsoft, and Gratian Lup (Microsoft Visual C++ Team) commented, on Jan 22, 2015:

Thank you for reporting the bug.
It has been fixed for the Visual Studio 2015 release.