This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix for PR31617


On 4/20/07, Olga Golovanevsky <OLGA@il.ibm.com> wrote:

This patch fixes the bug when multiple_of_p is called with top is integer_cstequal to 4 and bottom is integer_cst equal to 0. In this case int_const_binop returns NULL_TREE that is not checked in multiple_of_p. This NULL_TREE is then passed to integer_zerop, which generate segmentation fault with it.

I think we should check for NUL_TREE return value from
int_const_binop in multipe_of_p function.

bootstrapped with powerpc-suse-linux, running testing for it now.

ok for mainline?

I think it's better to check for bottom being zero in the predicate before, like

   case INTEGER_CST:
     if (TREE_CODE (bottom) != INTEGER_CST
+           || integer_zerop (bottom)
         || (TYPE_UNSIGNED (type)
             && (tree_int_cst_sgn (top) < 0
                 || tree_int_cst_sgn (bottom) < 0)))
       return 0;
     return integer_zerop (int_const_binop (TRUNC_MOD_EXPR,
                                            top, bottom, 0));

because this is the only case integer_zerop may return NULL.

Richard.

Olga

Index: fold-const.c
===================================================================
--- fold-const.c  (revision 123987)
+++ fold-const.c  (working copy)
@@ -13213,9 +13213,18 @@
            && (tree_int_cst_sgn (top) < 0
              || tree_int_cst_sgn (bottom) < 0)))
      return 0;
-      return integer_zerop (int_const_binop (TRUNC_MOD_EXPR,
-                                  top, bottom, 0));
+      {
+     tree t;
+
+     t = int_const_binop (TRUNC_MOD_EXPR, top, bottom, 0);

+     if (t)
+       return integer_zerop (t);
+     else
+       return 0;
+
+      }
+
     default:
       return 0;
     }







Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]