C32 fatal error C1001: Internal error occurred in the compiler

When compiling in release mode, the following error appears.

1>d:\users\eyal\projects\code\yalla\core\src\runbox\win32\window.cpp : fatal error C1001: An internal error has occurred in the compiler. 1> (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 249) 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> link!RaiseException()+0x48 1> link!CxxThrowException()+0x65 1> link!std::_Xout_of_range()+0x1f 1> link!InvokeCompilerPass()+0x1b4e2 1> link!InvokeCompilerPass()+0x22efe 1> link!InvokeCompilerPass()+0x2332e 1> link!InvokeCompilerPass()+0x232f9 1> link!InvokeCompilerPass()+0x233cb 1> link!InvokeCompilerPass()+0x22b04 1> link!InvokeCompilerPass()+0x22d86 1> link!DllGetC2Telemetry()+0x115837 1> 1> 1> 1>LINK : fatal error LNK1257: code generation failed 

I am using VS2015 Update 2 RC.

I'm not sure, but maybe this is a bug in the optimizer?

The code calling it is as follows:

window.h

 class Window { public: Window(); ~Window(); void show(); void hide(); private: class NativeControl; std::unique_ptr<NativeControl> _window; }; 

window.cpp

 class Window::NativeControl : public NativeWindow { public: NativeControl() : NativeWindow() { } }; Window::Window() : _window(std::make_unique<Window::NativeControl>()) { } Window::~Window() { } void Window::show() { _window->show(WindowShowMode::Show); } void Window::hide() { _window->show(WindowShowMode::Hide); } 

NativeWindow is a native window of any OS.

Here is the working code compiled using GCC 5.1: https://ideone.com/4YvjRK

Just to take a note.

If I remove the inheritance and replace it with something like this.

 class Window::NativeControl { public: void show(WindowShowMode showMode) { } }; 

Everything will be fine!

Here is the same code compiled with GCC 5.1 without inheritance: https://ideone.com/Mu0A42

What seems to be causing this behavior is the output of NativeControl from NativeWindow.

Actions to reproduce it as follows:

  • Remove the dtor declaration and definitions from the Window class.
  • Try to build (do not rebuild).
  • The compiler will complain and give you a bunch of errors.

1> C: \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ VC \ include \ memory (1194): error C2338: cannot delete incomplete type 1> 1> 1> C: \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ VC \ include \ memory (1195): warning C4150: deleting a pointer to an incomplete type 'Yalla :: Window :: NativeControl'; no destructor called 1>
d: \ Users \ Eyal \ Projects \ Code \ Yalla \ kernel \ SRC \ runbox \ enable \ window.h (13): note: see the declaration "Yalla :: Window :: NativeControl" 1>
window.cpp 1> 1> Build FAILED.

  1. Add dtor to the Window class.
  2. Create again (do not rebuild).
  3. At this point, the compiler should complain about the following error: "fatal error C1001: internal error occurred in the compiler."

The interesting part is that performing the rebuild seems to fix the problem!

What I want to achieve basically has the actual implementation of NativeWindow in another file, mainly for simplicity and not so much for reuse.

I suppose that instead of doing this in inheritance, which might confuse the unique_ptr pattern, I can also do it with composition and expose the NativeWindow instance via getter, and that might work, but the question is, are there any better ways to do this

I have been re-reading C ++ after a very long time, I have not touched it, so if some of the things that I do do not make sense, please tell me about it!

Update:

The C ++ standard says:

The parameter T of unique_ptr may be incomplete.

I found a post about this on Herb Sutter's blog.

+6
source share
1 answer

similar error with

(compiler file 'f: \ dd \ vctools \ compiler \ utc \ src \ p2 \ main.c', line 255)

the change was changed Properties->Linker->Optimization->Link Time Code Generation /LTCG:incremental from /LTCG:incremental to /LTCG

Studio 2015 Update 3

0
source

Source: https://habr.com/ru/post/1245065/


All Articles