py/mpz: Remove unreachable code in mpn_or_neg functions.
diff --git a/py/mpz.c b/py/mpz.c
index 1dd177b..1861840 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -308,9 +308,13 @@
carryi >>= DIG_SIZE;
}
- if (0 != carryi) {
- *idig++ = carryi;
- }
+ // At least one of j,k must be negative so the above for-loop runs at least
+ // once. For carryi to be non-zero here it must be equal to 1 at the end of
+ // each iteration of the loop. So the accumulation of carryi must overflow
+ // each time, ie carryi += 0xff..ff. So carryj|carryk must be 0 in the
+ // DIG_MASK bits on each iteration. But considering all cases of signs of
+ // j,k one sees that this is not possible.
+ assert(carryi == 0);
return mpn_remove_trailing_zeros(oidig, idig);
}
@@ -334,9 +338,8 @@
carryi >>= DIG_SIZE;
}
- if (0 != carryi) {
- *idig++ = carryi;
- }
+ // See comment in above mpn_or_neg for why carryi must be 0.
+ assert(carryi == 0);
return mpn_remove_trailing_zeros(oidig, idig);
}