relaxxx
relaxxx

Reputation: 7824

Possible bug in Visual Studio 2010 linker (minimal testcase included)

Here is minimal test example, which makes my Visual Studio 2010 crashed during linkage in Release mode. (just an example, no meaningful code)

#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;
}

output:

 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

In Debug mode it builds just fine.

When func() is not called it builds just fine.

When float is changed to int it builds just fine. (??)

Is this a compiler bug? Can somebody reproduce it?

I have Visual Studio 2010 Ultimate 10.0.40219.1 SP1

Upvotes: 3

Views: 678

Answers (2)

Yalon Lotan
Yalon Lotan

Reputation: 21

I had the same problem. It occurred after having deleted empty destructos. After restoring them the problem disappeared. I didn't try it on the example above, but my suggestion is to add:

~Foo() {}

~Bar() {}

Upvotes: 0

Luchian Grigore
Luchian Grigore

Reputation: 258568

Yes, a crash in any program is a bug, unless crashing is one of the features of that program (there are no programs that I know of that advertise crashing as a feature).

You're best off sending the error report or taking it directly to the MS forums.

Upvotes: 2

Related Questions