[Issue 12503] Bad optimization with scope(success) and return statement

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 9 01:45:10 PDT 2014


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

--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> ---
The lowered code generated by front-end will cause same issue.

void fun(string a)
{
    string b = a;
    bool __os1 = false;
    try
    {
        try
        {
            a = null;
            return ;
        }
        catch (Throwable __o2)
        {
            __os1 = true;
            throw __o2;
        }
    }
    finally
    {
        if (!__os1)
            assert(a != b);
    }
}

void main()
{
    fun("foo");
}

It seems to be caused by "copy propagation" in dmd-backed optimizer, done by
copyprop() in dmd/src/backend/gopher.c.

--


More information about the Digitalmars-d-bugs mailing list