C ++ 11 constexpr导致编译器内部错误(C1001) [英] C++11 constexpr causes compiler's internal error (C1001)
问题描述
我正在使用Visual Studio 2015 Update 3。
I am using Visual Studio 2015 Update 3.
我遇到致命错误:
(代码C1001):编译器发生内部错误。
(code C1001) : An internal error has occurred in the compiler.
以下是代码:
template<typename T>
constexpr T epsilon = std::numeric_limits<T>::epsilon();
我阅读了它在Visual Studio Update 2中已修复的问题。有人可以解释一下为什么我会收到此错误?
I read it was fixed in Visual Studio Update 2. Can someone explain me why I am getting this error? Thanks in advance.
推荐答案
任何内部错误(ICE)都是编译器错误。之所以得到它,是因为您碰巧触发了该错误。对于此编译器,您可以在Microsoft Connect上对其进行报告。
Any internal error (ICE) is a compiler bug. You get it because you have happened to trigger that bug. For this compiler you can report it at Microsoft Connect.
对于此类报告,您需要一个示例,该示例具有预期的正确结果和错误的结果。
For such a report you need an example with an expected correct result, and the erroneous result.
以下测试程序进行编译和处理;在MinGW g ++ 5.1上可以很好地运行
The following test program compiles & runs nicely with MinGW g++ 5.1
#include <limits>
template<typename T>
constexpr T epsilon = std::numeric_limits<T>::epsilon();
#include <iostream>
using namespace std;
auto main() -> int
{
cout << epsilon<double> << endl;
}
输出:
2.22045e-016
使用Visual C ++ 2015 update 2会生成ICE:
With Visual C++ 2015 update 2 it produces an ICE:
foo.cpp(10): fatal error C1001: An internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\cxxfe\sl\p1\c\symbols.c', line 28114)
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
foo.cpp(10): note: see reference to variable template 'const double epsilon' being compiled
编译器版本:
> cl /nologo- 2>&1 | find "++"
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23725 for x86
这篇关于C ++ 11 constexpr导致编译器内部错误(C1001)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!