Thread overview
[Issue 5628] New: std.math unittest disabled
Feb 20, 2011
Brad Roberts
May 01, 2011
Brad Roberts
Jan 02, 2012
Brad Roberts
[Issue 5628] std.math unittest disabled - roundoff error in pow() on SSE2
Apr 09, 2013
Don
February 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5628

           Summary: std.math unittest disabled
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: braddr@puremagic.com


--- Comment #0 from Brad Roberts <braddr@puremagic.com> 2011-02-20 14:25:05 PST ---
The test either takes an enormous amount of time or it goes into an infinite loop somewhere.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5628



--- Comment #1 from Brad Roberts <braddr@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: -------
January 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5628



--- Comment #2 from Brad Roberts <braddr@puremagic.com> 2012-01-01 21:24:28 PST ---
The bug in comment 1 is fixed.  There are 3 asserts left that fail w/in std.math:

   assert(pow(xd, neg2) == 1 / (x * x));
   assert(pow(xf, neg8) == 1 / ((x * x) * (x * x) * (x * x) * (x * x)));

   assert(feqrel(real.min_normal/8,real.min_normal/17)==3);

They're currently versioned out for x86_64

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5628


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|DMD                         |Phobos
            Summary|std.math unittest disabled  |std.math unittest disabled
                   |                            |- roundoff error in pow()
                   |                            |on SSE2
         OS/Version|Linux                       |All
           Severity|critical                    |normal


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2013-04-09 02:28:41 PDT ---
The remaining bug in comment 2 is just a rounding error.
The last bit of 1/ x*x  is different when the intermediate values are 80 bit
reals, vs when they are 64 bit doubles.

It is a bug, but it's not a compiler bug, just a fairly minor Phobos one.

Dropping severity to normal, and changing to Phobos.

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