https://issues.dlang.org/show_bug.cgi?id=10664

--- Comment #5 from Walter Bright <bugzi...@digitalmars.com> ---
I.e. this works:

import core.exception;
import core.bitop;

Exception collectExceptionE(int delegate () expression, ref int result)
{
    try
    {
        result = expression();
    }
    catch (Exception e)
    {
        core.bitop.volatileLoad(cast(size_t*)Exception.classinfo); <*****
        return e;
    }
    return null;
}

RangeError collectExceptionR(int delegate () expression, ref int result)
{
    try
    {
        result = expression();
    }
    catch (RangeError e)
    {
        core.bitop.volatileLoad(cast(size_t*)RangeError.classinfo); <*****
        return e;
    }
    return null;
}

void main()
{
    int b;
    int foo() { throw new Exception("blah"); }
    assert(collectExceptionE(&foo, b));

    int[] a = new int[3];
    int goo() { return a[4]; }
    collectExceptionR(&goo, b);
}

--

Reply via email to