c++ - Visual Studio 2010 链接器中的可能错误(包括最小测试用例)

标签 c++ visual-studio-2010 compiler-errors

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

在 Debug模式下,它构建得很好。

当未调用 func() 时,它构建得很好。

float 更改为 int 时,它构建得很好。 (??)

这是编译器错误吗?有人可以重现吗?

我有 Visual Studio 2010 Ultimate 10.0.40219.1 SP1

最佳答案

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

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

关于c++ - Visual Studio 2010 链接器中的可能错误(包括最小测试用例),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15790642/

相关文章:

visual-studio-2010 - Visual Studio 2010 看起来 "zoomed in"

c++ - 处理 map.find 和初始化的编译问题

haskell - 无法将预期类型 `Int' 与实际类型 `m0 Int' 匹配

compiler-errors - 尽管受到限制,但值(value)还不够长

c++ - 写入 vector 数组时,fwrite 因参数无效而失败

相同例程,不同成员变量类型时的c++类声明

c++ - 如何删除 C++ dll 中 auto_ptr 类型的对象

c# - 使用 C# 和 .NET 2.0 连接到本地 MySQL 数据库时出现问题

c++ - operator<< 智能指针重载

c++ - 如何使从科学计数法的转换更精确?