This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Stopgap bugfix for 20040303-1.c
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 04 Mar 2004 11:34:41 -0700
- Subject: [tree-ssa] Stopgap bugfix for 20040303-1.c
- Reply-to: law at redhat dot com
Given:
typedef struct input {
struct input *next;
} input_t;
static input_t *inputs = (input_t *)((void *)0);
void
RemoveInput(unsigned long id)
{
input_t *ip;
input_t *prev;
while (1)
if (ip == (input_t *)id)
break;
if (ip == (input_t *)((void *)0))
return;
prev->next = ip->next;
}
Compiling with -O2 on the tree-ssa branch would cause a segfault. The
problem is we lost the typecast in the first conditional. We then had
a conditional which tested for equality between a pointer an integer.
On the path where those were equal we then proceeded to propagate the
integer variable into the uses of the pointer variable.
At which point all bets were off.
Fundamentally this is a stop-gap until we can rewrite the folder. Richard
and I discussed some design issues earlier this week and I'm hoping that
means he's going to get the folder rewrite jump-started and that ultimately
we can change all this code to be more sensible.
Bootstrapped and regression tested. Also verified that it fixes a few
build failures when using the tree-ssa compiler to build FC2-test1 from
source.
* fold-const.c (fold): When rebuilding the expression after a
call to fold_relational_hi_lo, make sure to convert the type of
the second argument to the type of the first.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.213.2.78
diff -c -p -r1.213.2.78 fold-const.c
*** fold-const.c 4 Mar 2004 15:38:44 -0000 1.213.2.78
--- fold-const.c 4 Mar 2004 18:28:08 -0000
*************** fold (tree expr)
*** 7487,7493 ****
return t1;
else if (code != TREE_CODE (t)
|| TREE_OPERAND (t, 0) != arg0 || TREE_OPERAND (t, 1) != arg1)
! t = build (code, type, arg0, arg1);
/* If this is an EQ or NE comparison of a constant with a PLUS_EXPR or
a MINUS_EXPR of a constant, we can convert it into a comparison with
--- 7487,7493 ----
return t1;
else if (code != TREE_CODE (t)
|| TREE_OPERAND (t, 0) != arg0 || TREE_OPERAND (t, 1) != arg1)
! t = build (code, type, arg0, convert (TREE_TYPE (arg0), arg1));
/* If this is an EQ or NE comparison of a constant with a PLUS_EXPR or
a MINUS_EXPR of a constant, we can convert it into a comparison with