Home Dashboard Directory Help
Search

Visual studio 2010 crashes when compiling 'execute on unwind' code by Rollie_


Status: 

Active


1
0
Sign in
to vote
Type: Bug
ID: 780863
Opened: 3/6/2013 4:56:55 PM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description


VC10 crashes when compiling the below code. Boost version is 1.53, visual studio version4.0.30319 SP1 Rel.

template <typename T>
struct ExecuteOnUnwindHelper
{    
    ExecuteOnUnwindHelper(T _functor) : mFunctor(_functor)
    {
    }

    ~ExecuteOnUnwindHelper()
    {
        mFunctor();
    }

    T mFunctor;
};

template <typename T>
auto ExecuteOnUnwind(T _func) -> boost::shared_ptr<ExecuteOnUnwindHelper<decltype(boost::bind(_func))>>
{
    return boost::shared_ptr<ExecuteOnUnwindHelper<decltype(boost::bind(_func))>>(new ExecuteOnUnwindHelper<decltype(boost::bind(_func))>(boost::bind(_func)));
}

template <typename T, typename T2>
auto ExecuteOnUnwind(T _func, T2 _arg1) -> boost::shared_ptr<ExecuteOnUnwindHelper<decltype(boost::bind(_func, _arg1))>>
{
    return boost::shared_ptr<ExecuteOnUnwindHelper<decltype(boost::bind(_func, _arg1))>>(new ExecuteOnUnwindHelper<decltype(boost::bind(_func, _arg1))>(boost::bind(_func, _arg1)));
}

template <typename T, typename T2, typename T3>
auto ExecuteOnUnwind(T _func, T2 _arg1, T3 _arg2) -> boost::shared_ptr<ExecuteOnUnwindHelper<decltype(boost::bind(_func, _arg1, _arg2))>>
{
    return boost::shared_ptr<ExecuteOnUnwindHelper<decltype(boost::bind(_func, _arg1, _arg2))>>(new ExecuteOnUnwindHelper<decltype(boost::bind(_func, _arg1, _arg2))>(boost::bind(_func, _arg1, _arg2)));
}

template <typename T, typename T2, typename T3, typename T4>
auto ExecuteOnUnwind(T _func, T2 _arg1, T3 _arg2, T4 _arg3) -> boost::shared_ptr<ExecuteOnUnwindHelper<decltype(boost::bind(_func, _arg1, _arg2, _arg3))>>
{
    return boost::shared_ptr<ExecuteOnUnwindHelper<decltype(boost::bind(_func, _arg1, _arg2, _arg3))>>(new ExecuteOnUnwindHelper<decltype(boost::bind(_func, _arg1, _arg2, _arg3))>(boost::bind(_func, _arg1, _arg2, _arg3)));
}

void func0(){wcout << L"cleanup 0" << endl;}

void func1(int a)
{
    wcout << L"cleanup 1" << endl;
}

void func2(int a, int b)
{
    wcout << L"cleanup 2" << endl;
}

void func3(int a, int b, int c, int d)
{
    wcout << L"cleanup 3" << endl;
}

void foo()
{
    int a = 5;
    auto eou0 = ExecuteOnUnwind(&func0);
    auto eou1 = ExecuteOnUnwind(&func1, a);
    auto eou2 = ExecuteOnUnwind(&func2, a, a);
    auto eou3 = ExecuteOnUnwind(&func3, a, a, a);
}
Details
Sign in to post a comment.
Posted by Microsoft on 3/10/2013 at 8:40 PM
The product team itself no longer directly accepting feedback for Microsoft Visual Studio 2010 and earlier products. You can get support for issues with Visual Studio 2010 and earlier by visiting one of the resources in the link below:
http://msdn.microsoft.com/en-us/vstudio/cc136615.aspx
Posted by Microsoft on 3/8/2013 at 10:52 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.