From 5e7b33383a284e4b28fb27561012f6d1f618ec5c Mon Sep 17 00:00:00 2001 From: Don Clugston Date: Wed, 11 Jul 2012 18:14:17 +0200 Subject: [PATCH] Fix issue 7973 BigInt %= long/ulong gives wrong value Previous fix only worked for const; this fixes immutable too. --- std/bigint.d | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/std/bigint.d b/std/bigint.d index 580a3624d8d..6508e6db30b 100644 --- a/std/bigint.d +++ b/std/bigint.d @@ -162,7 +162,7 @@ public: else static if (op=="%") { assert(y!=0, "Division by zero"); - static if (is(const(T) == const(long)) || is( const(T) == const(ulong) )) + static if (is(immutable(T) == immutable(long)) || is( immutable(T) == immutable(ulong) )) { this %= BigInt(y); } @@ -581,11 +581,14 @@ unittest // Recursive division, bug 5568 // Bug 7973 auto a7973 = 10_000_000_000_000_000; const c7973 = 10_000_000_000_000_000; + immutable c7973 = 10_000_000_000_000_000; BigInt v7973 = 2551700137; v7973 %= a7973; assert(v7973 == 2551700137); v7973 %= c7973; assert(v7973 == 2551700137); + v7973 %= i7973; + assert(v7973 == 2551700137); // 8165 BigInt[2] a8165; a8165[0] = a8165[1] = 1;