C++致命错误 C1001:编译器中发生内部错误
C++ fatal error C1001: An internal error has occurred in the compiler
在发布模式下编译时出现以下错误。
1>d:userseyalprojectscodeyallacoresrcrunboxwin32window.cpp : fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'f:ddvctoolscompilerutcsrcp2main.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
我正在使用VS2015更新2 RC。
我不确定,但也许这是优化器中的错误?
导致它的代码如下:
窗口.h
class Window {
public:
Window();
~Window();
void show();
void hide();
private:
class NativeControl;
std::unique_ptr<NativeControl> _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是任何操作系统的本机窗口。
以下是使用 GCC 5.1 编译的工作代码: https://ideone.com/4YvjRK
只是为了做一个笔记。
如果我删除继承并将其替换为这样的东西。
class Window::NativeControl {
public:
void show(WindowShowMode showMode)
{
}
};
它会正常工作!
以下是使用 GCC 5.1 编译的相同代码,没有继承:https://ideone.com/Mu0A42
似乎导致这种行为的是NativeWindow的NativeControl派生。
重现它的步骤如下:
- 从 Window 类中删除 dtor 声明和定义。
- 尝试构建(而不是重建)。
- 编译器会抱怨并给你一堆错误。
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\memory(1194):错误 C2338:无法删除不完整的类型 1> 1> 1>C:\程序文件 (x86)\Microsoft Visual Studio 14.0\VC\include\memory(1195):警告 C4150:删除指向不完整类型"Yalla::Window::NativeControl"的指针;未调用析构函数 1>
d:\Users\Eyal\Projects\Code\Yalla\core\src\runbox\include\window.h(13): 注意:请参阅"Yalla::Window::NativeControl"的声明 1>
窗口.cpp 1> 1>生成失败。
- 将 dtor 添加回 Window 类。
- 再次生成(不是重新生成)。
- 此时,编译器应报告以下错误"致命错误 C1001:编译器中发生内部错误"。
有趣的是,进行重建似乎可以解决问题!
我想要实现的基本上是在不同的文件中实现 NativeWindow,主要是为了简单起见,而不是关于可重用性。
我想与其在继承中这样做,这可能会混淆unique_ptr模板,我还可以通过组合并通过 getter 公开 NativeWindow 的实例,它可能会起作用,但问题是是否有更好的方法可以做到这一点?
我正在重新学习C++很长一段时间后我没有碰它,所以如果我正在做的一些事情没有意义,请告诉我!
更新:
C++标准说:
unique_ptr的模板参数 T 可能是不完整的类型。
我在Herb Sutter的博客中找到了一篇关于它的文章。
类似的错误
(编译器文件 'f:\dd\VCtools\Compiler\utc\SRC\P2\main.c',第 255 行)
已修复更改Properties->Linker->Optimization->Link Time Code Generation
从/LTCG:incremental
到/LTCG
工作室 2015 更新 3
构建一个琐碎的C++命令行应用程序并使用Microsoft Visual Studio Community 2019 版本 16.6.2 时遇到了类似的致命错误。
将默认/LTCG:incremental
更改为/LTCG
project -> properties -> linker -> optimization
以进行release
配置解决了该问题。
补充一点,此错误是在最近的VS2019更新之一(不确定是哪个特定的更新)之后开始的。
我解决了这个问题以 64 位链接大库。Visual Studio 尝试使用默认(32 位链接)。
Configuration Properties -> Advanced -> Preferred Build Tool Architecture -> 64-bit (x64)
与编译器文件 p0io.c 相关的error C1001
主要是由于启用"使用 Unicode UTF-8"支持全球语言的区域设置。您可以看到有关具体原因的链接。您可以单击
Time &Language -> Region-> Additional date, time, ®ional settings-> Region-> Administrative->Change system locale
并关闭 UTF-8。
- 致命错误 C1001 :vs2017 15.8.4 的内部错误(编译器文件"msc1.cpp",第
- mingw32_gt_pch_use_address中的内部错误,在config/i386/host-mingw32.c
- 有关使用标志位设置内部错误标志的说明
- 致命错误 C1001:编译器中发生内部错误。'f:\dd\VCtools\Compiler\cxFE\SL\P1\C\P0io.c'
- 在函数内部错误定位后,从函数中释放返回的指针会导致芯片崩溃
- ssl3_read_bytes:TLSV1警报内部错误,安全套接字,OpenSSL,C ,获取HTTPS页面
- 构建 C++11 代码时 Coverity 中的内部错误
- 重新打开和 cout 创建内部错误
- 使用variadic概念模板时GCC内部错误
- C1001:编译器中包含 <boost/shared_ptr.hpp 时发生内部错误>
- 错误 C1001:编译器中发生内部错误
- CDT 在以下期间发生内部错误: "Setting up indexer"
- 代码块中存在内部错误
- 致命错误C1001:编译器中发生内部错误
- C++致命错误 C1001:编译器中发生内部错误
- 错误 C1001:调试模式下的编译器中发生内部错误
- 致命错误 C1001:尝试使用模板时出现内部错误
- GDB 在启动时崩溃(内部错误:follow_die_offset)
- C++ CodeDOM 解析器错误:行:75,列:57 ---内部错误
- 嵌套类模板专用化未正确匹配+msvc内部错误