[Issue 2832] New: pure function too pure

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 11 16:26:22 PDT 2009


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

           Summary: pure function too pure
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: andrei at metalanguage.com


pure int fun(int d, int divisor)
{
    if (d < 0)
        d -= divisor - 1;
    return d / divisor;
}

This doesn't compile because d is assumed to be constant. It doesn't have to
because it's a private copy of the function. Beware when fixing this - any
indirectly-referenced data is not part of function's private state.


-- 



More information about the Digitalmars-d-bugs mailing list