Bug 11583 – bigint bug

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-22T19:48:00Z
Last change time
2014-02-23T17:43:49Z
Keywords
pull
Assigned to
nobody
Creator
yuri.musashi.miwa.tamura

Comments

Comment #0 by yuri.musashi.miwa.tamura — 2013-11-22T19:48:32Z
import std.stdio; import std.bigint; void main() { BigInt x = 0; writeln(x > 0); } => true This seems new in v2.064.
Comment #1 by hsteoh — 2013-11-23T10:08:35Z
This is caused by the changes in commit 202d182152575db1d744ed5ee89b05a39e5a807b. BigUint.opCmp(Tulong y) returns the wrong result for comparison with 0.
Comment #2 by hsteoh — 2013-11-23T20:53:34Z
Comment #3 by github-bugzilla — 2013-12-04T23:47:05Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/8f132413dd17114ab8a1f1bb1589098602f785a6 Fix issue 11583. The problem is that the assumption that the first word of a BigUint is always non-zero is false when BigUint == biguintcore.ZERO, which is defined to be [0]. So we need to check for that case in BigUint.opCmp(ulong). Also, crash-proof BigUint's invariant, since it would cause an out-of-bounds array access if a bug causes data.length==0. https://github.com/D-Programming-Language/phobos/commit/5ef0d3428fd8fd1f11d5469f1330ffa963018e50 Merge pull request #1715 from quickfur/issue11583 Fix issue 11583.
Comment #4 by hsteoh — 2013-12-05T07:48:37Z
Verified fixed in git HEAD.
Comment #5 by safety0ff.bugz — 2014-02-23T17:43:49Z
*** Issue 12234 has been marked as a duplicate of this issue. ***