This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR30338, ICE in fold_comparison
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 31 Dec 2006 15:01:47 +0100
- Subject: [PATCH] Fix PR30338, ICE in fold_comparison
This fixes an ICE in fold_comparison due to a stack overflow due to infinite
folding. The cause of this is we create mismatched types in
/* Convert -1 - A to ~A. */
if (INTEGRAL_TYPE_P (type)
&& integer_all_onesp (arg0))
return fold_build1 (BIT_NOT_EXPR, type, arg1);
Bootstrapped and tested on i686-pc-linux-gnu, committed to mainline.
Richard.
2006-12-31 Richard Guenther <rguenther@suse.de>
PR middle-end/30338
* fold-const.c (fold_binary): Fix type-mismatch in folding
of -1 - A to ~A.
* gcc.c-torture/compile/pr30338.c: New testcase.
2006-12-31 Richard Guenther <rguenther@suse.de>
PR middle-end/30338
* fold-const.c (fold_binary): Fix type-mismatch in folding
of -1 - A to ~A.
* gcc.c-torture/compile/pr30338.c: New testcase.
Index: fold-const.c
===================================================================
*** fold-const.c (revision 120243)
--- fold-const.c (working copy)
*************** fold_binary (enum tree_code code, tree t
*** 9009,9015 ****
/* Convert -1 - A to ~A. */
if (INTEGRAL_TYPE_P (type)
&& integer_all_onesp (arg0))
! return fold_build1 (BIT_NOT_EXPR, type, arg1);
if (! FLOAT_TYPE_P (type))
{
--- 9119,9125 ----
/* Convert -1 - A to ~A. */
if (INTEGRAL_TYPE_P (type)
&& integer_all_onesp (arg0))
! return fold_build1 (BIT_NOT_EXPR, type, op1);
if (! FLOAT_TYPE_P (type))
{
Index: testsuite/gcc.c-torture/compile/pr30338.c
===================================================================
*** testsuite/gcc.c-torture/compile/pr30338.c (revision 0)
--- testsuite/gcc.c-torture/compile/pr30338.c (revision 0)
***************
*** 0 ****
--- 1,13 ----
+ /* We used to do folding with mismatched types which caused us to
+ infinitely loop in comparison foldings. */
+
+ extern char *grub_scratch_mem;
+ int testload_func (char *arg, int flags)
+ {
+ int i;
+ for (i = 0; i < 0x10ac0; i++)
+ if (*((unsigned char *) ((0x200000 + i + (int) grub_scratch_mem)))
+ != *((unsigned char *) ((0x300000 + i + (int) grub_scratch_mem))))
+ return 0;
+ return 1;
+ }