[Issue 5628] std.math unittest disabled

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 30 22:25:08 PDT 2011


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



--- Comment #1 from Brad Roberts <braddr at puremagic.com> 2011-04-30 22:21:19 PDT ---
Reduced test case:

Must be built with debugging turned on, otherwise it doesn't loop:
  dmd -m64 -gc  bug-pow.d

module bug;

real pow(real x, ubyte n) @trusted pure nothrow
{
    real p = 1.0;
    ubyte m = n;

    switch (n)
    {
    default:
    }

    while (1)
    {
        if (n & 1)
            p *= x;
        n >>= 1;
        if (!n)
            break;
        x *= x;
    }
    return p;
}

int main()
{
    immutable real x = 46;
    immutable ubyte three = 3;
    assert(pow(x,three) == x * x * x);

    return 0;
}

Extracted from std/math.d, function:

typeof(Unqual!(F).init * Unqual!(G).init) pow(F, G)(F x, G n) @trusted pure
nothrow
if (isIntegral!(F) && isIntegral!(G))

And it's following unittest.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list