这是最小的测试示例,它使我的 Visual Studio 2010 在Release
模式链接期间崩溃。(只是一个例子,没有有意义的代码)
#include <iostream>
#include <functional>
struct Foo
{
typedef std::function<void()> Func;
Func m_func;
float m_f;
Foo(Func func, float f)
:m_func(func),
m_f(f)
{
func();
}
};
struct Bar
{
Bar(): foo(std::bind(&Bar::bar, this), 1.0f)
{
std::cout << "foobar";
}
Foo foo;
void bar(){ std::cout << "bar"; }
};
int main()
{
Bar b;
}
输出:
fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c[0x5AE87EF6:0x00000009]', line 183)
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>
1>LINK : fatal error LNK1000: Internal error during IMAGE::BuildImage
1>
1> Version 10.00.40219.01
1>
1> ExceptionCode = C0000005
1> ExceptionFlags = 00000000
1> ExceptionAddress = 5AE87EF6 (5AE40000) "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\c2.dll"
1> NumberParameters = 00000002
1> ExceptionInformation[ 0] = 00000000
1> ExceptionInformation[ 1] = 00000009
1>
1> CONTEXT:
1> Eax = 040570CC Esp = 0042ED34
1> Ebx = 5B09E2A8 Ebp = 0042ED4C
1> Ecx = 0405660C Esi = 04010660
1> Edx = 00000000 Edi = 0000001E
1> Eip = 5AE87EF6 EFlags = 00010287
1> SegCs = 00000023 SegDs = 0000002B
1> SegSs = 0000002B SegEs = 0000002B
1> SegFs = 00000053 SegGs = 0000002B
1> Dr0 = 00000000 Dr3 = 00000000
1> Dr1 = 00000000 Dr6 = 00000000
1> Dr2 = 00000000 Dr7 = 00000000
在调试模式下,它构建得很好。
当func()
不被调用时,它构建得很好。
何时float
更改为int
它构建就好了。(??)
这是编译器错误吗?有人可以复制吗?
我有 Visual Studio 2010 Ultimate 10.0.40219.1 SP1