[Issue 2188] New: man-or-boy test fails with access violation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 30 23:56:40 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2188

           Summary: man-or-boy test fails with access violation
           Product: D
           Version: 2.016
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: bugzilla at digitalmars.com


because it doesn't handle lazy parameters right when generating a closure.
Works fine in D 1.0.

int a(int k, lazy int x1, lazy int x2, lazy int x3, lazy int x4, lazy int x5)
{
    int delegate() b;
    b = { k -= 1; return a(k, b(), x1, x2, x3, x4); };
    if (k <= 0)
        return x4 + x5;
    else
        return b();
}

int main()
{
    assert(a(10, 1, -1, -1, 1, 0) == -67);
    return 0;
}


-- 



More information about the Digitalmars-d-bugs mailing list