www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18434] New: Failing case of BigInt gcd

https://issues.dlang.org/show_bug.cgi?id=18434

          Issue ID: 18434
           Summary: Failing case of BigInt gcd
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: hsteoh quickfur.ath.cx

Code:
------
import std.bigint;
import std.numeric;
void main() {
        auto g1 = gcd(0, 1); // OK
        auto g2 = gcd(BigInt(0), BigInt(1)); // NG
}
------

Output:
------
core.exception.AssertError /usr/src/d/phobos/std/numeric.d(2699): Assertion
failure
----------------
??:? _d_assertp [0xc9cf7171]
??:? pure nothrow std.bigint.BigInt
std.numeric.gcd!(std.bigint.BigInt).gcd(std.bigint.BigInt, std.bigint.BigInt)
[0xc9cf5770]
??:? _Dmain [0xc9cf5079]
------

The offending line in std.numeric is in the `static if (canUseBinaryGcd)`
block, in the do-loop:

-----
assert((a & 1) != 0);
-----

--
Feb 13 2018