https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112733

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Actually, maybe better variant of the first fix in the above comment would be:
--- gcc/wide-int.cc.jj  2023-11-28 16:56:50.000000000 +0100
+++ gcc/wide-int.cc     2023-11-28 16:58:02.268776755 +0100
@@ -1985,6 +1985,8 @@ wi::divmod_internal (HOST_WIDE_INT *quot

   if (remainder)
     {
+      if (n > dividend_blocks_needed)
+       n = dividend_blocks_needed;
       *remainder_len = wi_pack (remainder, b_remainder, n, dividend_prec);
       /* The remainder is always the same sign as the dividend.  */
       if (dividend_neg)
where the check which is useless for multiplication and quotient is done only
in the problematic spot - remainder.

Reply via email to