3

这是最小的测试示例,它使我的 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

4

2 回答 2

2

是的,任何程序中的崩溃都是错误,除非崩溃是该程序的功能之一(据我所知,没有任何程序将崩溃作为一项功能进行宣传)。

您最好发送错误报告或将其直接带到 MS 论坛。

于 2013-04-03T14:51:45.960 回答
0

我有同样的问题。它发生在删除空的破坏后。恢复它们后,问题就消失了。我没有在上面的示例中尝试过,但我的建议是添加:

~Foo() {}

〜酒吧(){}

于 2014-12-25T13:39:08.897 回答