I recently switched our product over to VS2010 from VS2008. Our solution consists of several native C++ projects and some managed C++ projects that link to those native projects.

The managed C++ projects are compiled with the /clr flag, of course. However, when compiling for x64, one of the files that includes one of the boost mutex headers causes the compiler to spit out the following error:

boost_1_43_0_sdk\include\boost\thread\win32\basic_timed_mutex.hpp(158): fatal error C1001: An internal error has occurred in the compiler

I've traced down the problem to the following piece of code in basic_timed_mutex.hpp:

void unlock()
{
    long const offset=lock_flag_value;

    // If I comment out this line, compilation works
    long const old_count=BOOST_INTERLOCKED_EXCHANGE_ADD(&active_count,lock_flag_value);

    if(!(old_count&event_set_flag_value) && (old_count>offset))
    {
        if(!win32::interlocked_bit_test_and_set(&active_count,event_set_flag_bit))
        {
            win32::SetEvent(get_event());
        }
    }
}

It would see the BOOST_INTERLOCKED_EXCHANGE_ADD macro causes the compiler to barf. Does anybody have any ideas on why this is, or how to fix it?

Cheers,
Soren