[Bug middle-end/66127] Division by zero gets folded away

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed May 13 14:42:00 GMT 2015


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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Like a more complete variant of

Index: gcc/tree.c
===================================================================
--- gcc/tree.c  (revision 223151)
+++ gcc/tree.c  (working copy)
@@ -4402,6 +4402,11 @@ build2_stat (enum tree_code code, tree t
   PROCESS_ARG (0);
   PROCESS_ARG (1);

+  if (code == TRUNC_DIV_EXPR
+      && (TREE_CODE (arg1) != INTEGER_CST
+         || integer_zerop (arg1)))
+    side_effects = 1;
+
   TREE_SIDE_EFFECTS (t) = side_effects;
   if (code == MEM_REF)
     {



More information about the Gcc-bugs mailing list