Visual Studio internal error C1001: A silly problem

Still with Visual Studio, I was surprised (given the 2015 version of Visual Studio works pretty well so far…) to find a compiler internal error the other day…

It appeared in the following way:

 1>c:\users\pando\desktop\projects\win32project1\win32project1\d3dapp.cpp(4): fatal error C1001: An internal error has occurred in the compiler.
1>  (compiler file ‘msc1.cpp’, line 1393)
1>   To work around this problem, try simplifying or changing the program near the locations listed above.
1>  Please choose the Technical Support command on the Visual C++
1>   Help menu, or open the Technical Support help file for more information
1>  INTERNAL COMPILER ERROR in ‘C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe’
1>      Please choose the Technical Support command on the Visual C++
1>      Help menu, or open the Technical Support help file for more information

So I was a little clueless about the IDE’s suggestion of « simplifying » my code (given it was already pretty simple…), so I started to do some extensive search, without great luck.

Then I looked at my code (a C++ constructor) that was looking like this:

It was partly copy/pasted from the header file. That’s when I realized the default value for  d3dDeviceFlags was still specified (it shouldn’t in the definition !).

So that’s why the Visual compiler was failing. Removing the « = 0 » immediately fixed it.

It seems this kind of error, which is a basic syntax error really, didn’t always trigger an internal error (I couldn’t find anyone on Google having the same issue). So be aware that with new versions of Visual Studio, silly errors like this one can produce unexpected compiler internal errors (actually, I think those never are expected). I was lucky my code was very short, but on larger codebases, this could become hard to spot.

 

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée.