[Issue 10664] Win64: exception handling does not work with COMDAT folding

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 9 19:45:24 UTC 2020


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

--- Comment #3 from Rainer Schuetze <r.sagitario at gmx.de> ---
Here's a version without lazy and templates:

import core.exception;

Exception collectExceptionE(int delegate () expression, ref int result)
{
    try
    {
        result = expression();
    }
    catch (Exception e)
    {
        return e;
    }
    return null;
}

RangeError collectExceptionR(int delegate () expression, ref int result)
{
    try
    {
        result = expression();
    }
    catch (RangeError e)
    {
        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);
}

I suspect that the functions need to be the exact same code, and only the
associated exception data differs. That's also why you cannot easily eliminate
the delegate call.

Please note that you have to remove /OPT:NOICF from sc.ini to reproduce, as it
was added as a workaround.

--


More information about the Digitalmars-d-bugs mailing list