Thread overview
[Issue 1637] New: regression: new unittest failure in std/math2.d, odd cosh() behavior
Nov 04, 2007
d-bugmail
Mar 09, 2008
d-bugmail
Aug 28, 2008
d-bugmail
November 04, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1637

           Summary: regression: new unittest failure in std/math2.d, odd
                    cosh() behavior
           Product: D
           Version: 2.007
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: braddr@puremagic.com


From std/math2.d:

616 real coth(real x)
617 {
618         return 1 / tanh(x);
619 }
620
621 unittest
622 {
623         assert(feq(coth(1), cosh(1) / sinh(1)));
624 }

This test fails with dmd 2.007 and doesn't with dmd 2.006 (using the 2.006 phobos code, 2.007's phobos needs dmd 2.007 to build, but there's no changes to the math code in phobos between 2.006 and 7).

My attempts to reduce the failure so far have been interesting.  Adding printf's of each of the function results shows that adding a writeln for cosh is enough to make the error go away.  One write of cosh(1) shows inf as the result.  Two writes of cosh(1): first is inf, second is 1.54308.

I tried pulling the test code out to it's own tiny .d file and it doesn't fail.
 It always prints 1.54308 for cosh(1).


-- 

March 09, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1637





------- Comment #1 from braddr@puremagic.com  2008-03-08 18:08 -------
Created an attachment (id=233)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=233&action=view)
stand alone test case

I figured out how to cut this test case out of the full library into a single .d file.  Change essentially _anything_ and the error goes away.

$ dmd -unittest bug1637.d && ./bug1637
Error: AssertError Failure bug1637.d(89)


-- 

August 28, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1637


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME




------- Comment #2 from bugzilla@digitalmars.com  2008-08-28 03:31 -------
Irrelevant for D 2.0 which has dropped std.math2.

Works in D 1.0 1.034.


--