[Issue 14829] [REG2.066.0] wrong code with -O -inline

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jul 27 00:35:04 PDT 2015


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

--- Comment #4 from Walter Bright <bugzilla at digitalmars.com> ---
Somewhat smaller test case that only requires -O to fail:

int decodeImpl(int[] str)
{
    return 1;
}

int[] stripLeft(int[] str)
{
    while (true)
    {
        int[] a = str;
        int[] s = a;
        int dc = decodeImpl(str);
        str = str[1 .. $];
        bool w = dc != 1;
        if (!w) return s;
    }
}

void main ()
{
    int[1] a = 2;
    assert (stripLeft(a)[0] == 2); // fails with -O
}

--


More information about the Digitalmars-d-bugs mailing list