www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14257] New: ICE(backend/go.c) with large static foreach

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

          Issue ID: 14257
           Summary: ICE(backend/go.c) with large static foreach
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: sinkuupump gmail.com

DMD fails to optimize code like the following, when foreach aggregate is
staticIota!(0, x >= 100).

Reduced test case:
template TypeTuple(TList...)
{
    alias TypeTuple = TList;
}

package template staticIota(int beg, int end)
{
    static if (beg + 1 >= end)
    {
        static if (beg >= end)
        {
            alias staticIota = TypeTuple!();
        }
        else
        {
            alias staticIota = TypeTuple!(+beg);
        }
    }
    else
    {
        enum mid = beg + (end - beg) / 2;
        alias staticIota = TypeTuple!(staticIota!(beg, mid), staticIota!(mid,
end));
    }
}

void test()
{
    int row;

    foreach (s; staticIota!(0, 100))
    {
        if (++row) row = 0;
    }
}



$ dmd -O -c test.d
Internal error: backend/go.c 242

--
Mar 07 2015