[Bug middle-end/70992] Infinite recursion between fold_build2_stat_loc and fold_binary_loc w/ -fwrapv

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon May 30 12:31:00 GMT 2016


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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The bad recursion happens between extract_muldiv_1

      /* The last case is if we are a multiply.  In that case, we can
         apply the distributive law to commute the multiply and addition
         if the multiplication of the constants doesn't overflow
         and overflow is defined.  With undefined overflow
         op0 * c might overflow, while (op0 + orig_op1) * c doesn't.  */
      if (code == MULT_EXPR && TYPE_OVERFLOW_WRAPS (ctype))
        return fold_build2 (tcode, ctype,
                            fold_build2 (code, ctype,
                                         fold_convert (ctype, op0),
                                         fold_convert (ctype, c)),
                            op1);

which does (0 % 0 + 1) * 2 -> (0 % 0) * 2 + 2 and the reverse transformation
fold_plusminus_mult_expr does.


More information about the Gcc-bugs mailing list