Declaring a static pointer in class [duplicate] - c++

While compiling on x64 plattform I am getting following error:
c:\codavs05\hpsw-sc\ovpacc\tools\codaaccesstest\coda_access.cpp(1572): fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\utc\src\p2\sizeopt.c', line 55)
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
------ Build started: Project: asyncexample, Configuration: Release Win32 ------
If I change settings to preprocessor file (Yes) i am not getting any error.
About my environment: Upgrading Microsoft Visual Studio 2005 to 2010
Please help.

I have had this problem with VS2015 while building locally in Windows.
In order to solve it, I deleted my build folder (Output Directory as seen in Properties/General) and rebuilt the project.
This always seems to help when strange things happen during the build.

I’ve encountered this error many times in VC++. Do the following steps. They’ve sometimes helped me with this issue:
Take a look at the exact location, pointed out by compiler error.
Find any external types or classes used there at that location.
Change the order of “include path” of those files found in step 2 and rebuild the solution.
I hope that help !!!!

I am getting same error with VC2012. Setting up the project properties Optimization to Disabled (/Od) resolved the issue.

In my solution, i've removed output dll file of the project, and I've made project rebuild.

I encountered the same error and spent quite a bit of time hunting for the problem. Finally I discovered that function that the error was pointing to had an infinite while loop. Fixed that and the error went away.

In my case was the use of a static lambda function with a QStringList argument. If I commented the regions where the QStringList was used the file compiled, otherwise the compiler reported the C1001 error. Changing the lambda function to non-static solved the problem (obviously other options could have been to use a global function within an anonymous namespace or a static private method of the class).

I got this error using boost library with VS2017. Cleaning the solution and rebuilding it, solved the problem.

I also had this problem while upgrading from VS2008 to VS2010.
To fix, I have to install a VS2008 patch (KB976656).
Maybe there is a similar patch for VS2005 ?

I got the same error, but with a different file referenced in the error message, on a VS 2015 / x64 / Win7 build. In my case the file was main.cpp. Fixing it for me was as easy as doing a rebuild all (and finding something else to do while the million plus lines of code got processed).
Update: it turns out the root cause is my hard drive is failing. After other symptoms prompted me to run chkdsk, I discovered that most of the bad sectors that were replaced were in .obj, .pdb, and other compiler-generated files.

I got this one with code during refactoring with a lack of care (and with templates, it case that was what made an ICE rather than a normal compile time error)
Simplified code:
void myFunction() {
using std::is_same_v;
for (auto i ...) {
myOtherFunction(..., i);
}
}
void myOtherFunction(..., size_t idx) {
// no statement using std::is_same_v;
if constexpr (is_same_v<T, char>) {
...
}
}

I had this error when I was compiling to a x64 target.
Changing to x86 let me compile the program.

Sometimes helps reordering the code. I had once this error in Visual Studio 2013 and this was only solved by reordering the members of the class (I had an enum member, few strings members and some more enum members of the same enum class. It only compiled after I've put the enum members first).

In my case, this was causing the problem:
std::count_if(data.cbegin(), data.cend(), [](const auto& el) { return el.t == t; });
Changing auto to the explicit type fixed the problem.

Had similar problem with Visual Studio 2017 after switching to C++17:
boost/mpl/aux_/preprocessed/plain/full_lambda.hpp(203): fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'msc1.cpp', line 1518)
1> To work around this problem, try simplifying or changing the program near the locations listed above.
Solved by using Visual Studio 2019.

I first encountered this problem when i was trying to allocate memory to a char* using new char['size']{'text'}, but removing the braces and the text between them solved my problem (just new char['size'];)

Another fix on Windows 10 if you have WSL installed is to disable LxssManager service and reboot the PC.

Related

Visual Studio 2019 "C1001 internal compiler error" only in Release

I'm getting a C1001 error while attempting to build in Visual Studio 2019 Version 16.7.2. This is a C++ project that has previously built fine until a change set I am attempting to build today.
The exact error is as follows: (with project specific path redacted)
1>d:\work\[...](82): fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'd:\agent\_work\3\s\src\vctools\compiler\utc\src\p2\main.c', line 187)
Notes below:
The error only happens in Release. Debug builds and runs.
If I turn off all optimizations in Release the error goes away.
The location where the error occurs seems to be unrelated to recent changes I have made to the project i.e. VS is reporting the error in a translation unit that had been building without problem until unrelated changes in another TU were made.
The location where the error occurs seems to not actually be problematic in the sense that if I comment out the implementation of the function there and just return a default value from the function so that the program is syntactically correct, the error occurs in the next the function in the same file.
Turning off Whole Program Optimization and Link Time Code Generation does not fix the problem.
SUGGESTIONS
Please:
Update your post with exact error text (if available)
Post your question to https://developercommunity.visualstudio.com/ as well
See if any of these links are applicable:
https://developercommunity.visualstudio.com/content/problem/710576/visual-studio-2019-1622-fatal-error-c1001-in-32-bi.html
https://social.msdn.microsoft.com/Forums/vstudio/en-US/165975b4-35e9-4b40-9524-e656a4e2f359/fatal-error-c1001-an-internal-error-has-occurred-in-the-compiler?forum=visualstudiogeneral
https://developercommunity.visualstudio.com/content/problem/664162/ice-on-valid-code-after-upgrading-to-1620.html
One way to notify Microsoft Support like this:
MSVS > Help > Send Feedback > Report a Problem
Here is a complete list of MSVS support options: https://visualstudio.microsoft.com/vs/support/
Update:
Thank you for copying/pasting the exact error message:
1>d:\work\[...](82): fatal error C1001: An internal error has occurred in the compiler.
1>(compiler file 'd:\agent\_work\3\s\src\vctools\compiler\utc\src\p2\main.c', line 187)
This is the MSVS file causing the error C1001: vctools\compiler\utc\src\p2\main.c
This is an existing Microsoft trouble report:
https://developercommunity.visualstudio.com/content/problem/210332/c1001-internal-error-compiler-file-fddvctoolscompi.html
Hi Roger,
Thanks for reporting the bug, and including an excellently
self-contained repro, so quickly. I've investigated and this seems to
be the same issue as
https://developercommunity.visualstudio.com/content/problem/209359/ice-with-fpfast-in-156-and-msvc-daily-1413263051-p.html.
I'm closing this as a duplicate just so that people can collect
context and work-around advice in the same location, and when the
other bug is marked fixed, you can assume that this one is too.
Thanks again,
Aaron Gorenstein
Software Engineer II
Searching for this error message/source module, I also found this: https://stackoverflow.com/a/63435683/421195
Please post back if either of these work for you!

Error in <limits> compiling an old code using VSC2019

I have an old code, but using Visual Studio Community 2017 had no problem to compile it. Yesterday, I updated to Visual Studio Community 2019 and I opened the old .vxproj file, but I got tens of errors like this while compiling include file limits:
limits(900,39): error C3615: constexpr function 'std::numeric_limits::quiet_NaN' cannot result in a constant expression
limits(901,30): message : failure was caused by call of undefined function or one not declared 'constexpr'
I guess the problem may be with the old .vxproj file, but I have no idea how can I fix it without creating a new project form scatch. Any help would be appreciated.
I have found the problem. There was a few preprocessor directives which caused the problem. After removig them I was able to compile:
__builtin_huge_val()=HUGE_VAL
__builtin_huge_valf()=HUGE_VALF
__builtin_nan=nan
__builtin_nanf=nanf
__builtin_nans=nan
__builtin_nansf=nanf
__is_assignable=__is_trivially_assignable
Once I have tried the Intel compiler in Visual Studio, it required these settings, but it seems I forgot to remove them.
I have decided not to delete this post, but answer my own question. It may be useful for someone with a similar problem, or if you want to make fun of your colleague :-) It took me a very long time to find out what the problem was.

How to repair Visual Studio locals/watches in C++ (Debug build)

Sometimes VS autos/locals/watches break and instead of variables/values all I have is different kinds of:
CXX0029: Error: not struct pointer
CXX0033: Error: error in OMF type information
CXX0072: Error: type information missing or unknown
CXX0025: Error: operator needs class/struct/union
Rebuilding project, cleaning PDB/NCB etc doesn't solve it. What can I do?
Look at this Microsoft support note on: FIX: CXX0033 Error in OMF Type from Forward Class Declaration
Once you fix the PCH problem cited in the support note, I think all your errors will go away.
There is in fact a solution that lets you keep using precompiled headers: check out this more recent KB article and the documentation of the /Yl switch - which seems specifically tailored to this error.
Just add to the stdafx.cpp (or your own custom /Yc file) command line '/Ylxxxx', where xxxx stands for an arbitrary function name in your lib.
I recently faced symptoms identical to yours (in VS2010), and that solved it for me.
Are you trying to debug the "release" build? If so, many local variables will not exist as "debuggable" elements. You can get around this (if you must debug the release build) by debugging at the assembly level and look at the register values (vs. stack values, where auto/local would be in the debug build) and cast them appropriately in the "watch window".
Otherwise, build the Debug build and debug that build version. You'll get assertions where preconditions are not met, relevant/irrelevant stuff dumped to your output window, and more straight-forward debug single stepping.
It helped me to switch from using a program database (/ZI) to "c7 compatible" (/Z7). Switching off precompiled headers did not make a difference. Neither did rebuilding.

Very Mysterious/Random C++ WDK STL 7 Error: iosfwd(202): error C2144: syntax error

I have the following trivial file named Temp.cpp:
#include <string>
int main() { return 0; }
and I'm trying to compile it with the following command-line in the Windows XP Free Build Environment, using WDK 7.1:
cl.exe /Iinc\api\crt\stl70 /Iinc\crt C:\Temp.cpp
and I'm getting really random errors like:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.207 for 80x86
C:\WinDDK\7600.16385.1\inc\api\crt\stl70\iosfwd(202) :
error C2144: syntax error : 'int' should be preceded by ';'
The error goes away if I use stl60 instead of stl70, but that doesn't solve the problem.
What's the cause of the problem?
Update: I tried uninstalling and installing the WDK again, but nothing changed. :(
Update 2: Okay, apparently the error is screaming out at the header file itself: _SCL_INSECURE_DEPRECATE is the cause. Does anybody know how to turn it off correctly? (If I just comment out the lines, I get a ton more errors regarding a bunch of other macros.)
Found the answer myself, through modifying the headers and guess'n'checking:
I need to have _STL70_ defined.
Which cl.exe are you picking up? If your path happens to have an older (VC6) compiler before the WDK one, you'd expect these errors. VC6 can't compile the STL as shipped with VC7
apparently the error is screaming out at the header file itself: _SCL_INSECURE_DEPRECATE is the cause. Does anybody know how to turn it off correctly?
If you're having problems with _SCL_INSECURE_DEPRECATE, try setting:
/D_SCL_SECURE_NO_DEPRECATE
But given the error message you're seeing it sounds like you're the compiling headers with a a compiler that's older than the headers support (so this might not get you very far anyway).

Error LNK1223 on ARM builds

eMbedded Visual C++ 3 project, that is building for PocketPC 2000. On the ARM build, the linker throws the following error:
fatal error LNK1223: invalid or corrupt file: file contains invalid pdata contributions
On SH3, the project compiles, links, and works. The project also works when built for ARM on Visual C++ 2005, but I need to test builds specifically from eVC3.
Any ideas, please? What's a pdata contribution and how do I affect (or disable) those? It's something to do with exception handling; I've tried disabling SEH by specifying /EHsc, to no effect.
Very weird. I tried commenting out everything in the file. The error went away when I commented out a function that was extern "C" void __declspec(naked) with no body (body #ifdef'fed away). I have similar functions in the project, but they did not throw any errors like this. Maybe a compiler bug...
No idea from me, but the Google-mind dredged up this thread which might give you a clue how to fix/workaround the problem... maybe:
http://www.pocketpcjunkies.com/Uwe/Forum.aspx/wince-pb/7477/Link-error-during-DEBUG-build
After looking at the error more closely, I finally figured out that this is
a side-effect of my hijacking of SC_SetDaylightTime() in the kernel with my
own version. Apparently, something that I'm doing in my code there is
causing the compiler to generate pdata entries that are wrong in some way.
A strategically-placed #ifndef worked around it.