This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
fold_indirect_ref bogous
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 27 Apr 2005 16:19:57 +0200 (CEST)
- Subject: fold_indirect_ref bogous
fold_indirect_ref, called from the gimplifier happily converts
const char *a;
...
*(char *)&a[x] = 0;
to
a[x] = 0;
confusing alias1 and ICEing in verify_ssa:
/net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
error: Statement makes a memory store, but has no V_MAY_DEFS nor
V_MUST_DEFS
# VUSE <ao_1>;
ao.ch[D.1242_5] = 0;
/net/alwazn/home/rguenth/src/gcc/cvs/gcc-4.1/gcc/testsuite/gcc.c-torture/execute/20031215-1.c:11:
internal compiler error: verify_ssa failed.
happens only for patched gcc where C frontend and fold happen to
produce .02.original:
;; Function test1 (test1)
;; enabled by -tree-original
{
if (ao.ch[ao.l] != 0)
{
*(char *) &ao.ch[(unsigned int) ao.l] = 0;
}
}
then, generic is already wrong:
test1 ()
{
int D.1240;
char D.1241;
unsigned int D.1242;
D.1240 = ao.l;
D.1241 = ao.ch[D.1240];
if (D.1241 != 0)
{
D.1240 = ao.l;
D.1242 = (unsigned int) D.1240;
ao.ch[D.1242] = 0;
}
(not the missing cast).
something like the following patch fixes this.
Richard.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.572
diff -c -3 -p -r1.572 fold-const.c
*** fold-const.c 26 Apr 2005 16:35:10 -0000 1.572
--- fold-const.c 27 Apr 2005 14:15:10 -0000
*************** fold_indirect_ref_1 (tree t)
*** 11322,11328 ****
tree sub = t;
tree subtype;
! STRIP_NOPS (sub);
subtype = TREE_TYPE (sub);
if (!POINTER_TYPE_P (subtype))
return NULL_TREE;
--- 11315,11321 ----
tree sub = t;
tree subtype;
! STRIP_TYPE_NOPS (sub);
subtype = TREE_TYPE (sub);
if (!POINTER_TYPE_P (subtype))
return NULL_TREE;