[Bug tree-optimization/85588] [6/7/8/9 Regression] -fwrapv miscompilation

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 3 09:34:00 GMT 2018


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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
A fix is probably as simple as

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c    (revision 259879)
+++ gcc/fold-const.c    (working copy)
@@ -472,7 +472,7 @@ negate_expr_p (tree t)
     case TRUNC_DIV_EXPR:
     case ROUND_DIV_EXPR:
     case EXACT_DIV_EXPR:
-      if (TYPE_UNSIGNED (type))
+      if (TYPE_OVERFLOW_WRAPS (type))
        break;
       if (negate_expr_p (TREE_OPERAND (t, 0)))
        return true;


More information about the Gcc-bugs mailing list