This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix for PR31617
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Olga Golovanevsky" <OLGA at il dot ibm dot com>
- Cc: "Martin Michlmayr" <tbm at cyrius dot com>, "Jan Hubicka" <jh at suse dot cz>, "Daniel Berlin" <dberlin at dberlin dot org>, "Kenneth Zadeck" <zadeck at naturalbridge dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 21 Apr 2007 11:21:36 +0200
- Subject: Re: [patch] Fix for PR31617
- References: <OF126EC723.E84920B5-ONC22572C3.00529E69-C22572C3.006DF840@il.ibm.com>
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;
}