From: Richard Guenther Date: Sun, 18 Dec 2005 22:20:31 +0000 (+0000) Subject: re PR tree-optimization/25481 (Segfault in tree-ssa-structalias.c) X-Git-Tag: releases/gcc-4.2.0~5247 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04743a370f720221d93f28807ec3349a6faf21ac;p=thirdparty%2Fgcc.git re PR tree-optimization/25481 (Segfault in tree-ssa-structalias.c) 2005-12-18 Richard Guenther PR tree-optimization/25481 * tree-ssa-structalias.c (handle_ptr_arith): Handle accesses we don't have a varinfo for. * gcc.dg/torture/pr25481.c: New testcase. From-SVN: r108763 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 98468169d1cc..6c9d1b509715 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-12-18 Richard Guenther + + PR tree-optimization/25481 + * tree-ssa-structalias.c (handle_ptr_arith): Handle + accesses we don't have a varinfo for. + 2005-12-17 Jon Grimm Janis Johnson Ben Elliston diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 417496112728..c12b7885c07b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-12-18 Richard Guenther + + PR tree-optimization/25481 + * gcc.dg/torture/pr25481.c: New testcase. + 2005-12-18 Ulrich Weigand PR rtl-optimization/21041 diff --git a/gcc/testsuite/gcc.dg/torture/pr25481.c b/gcc/testsuite/gcc.dg/torture/pr25481.c new file mode 100644 index 000000000000..3072e5ecb76d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr25481.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +struct s { + int *blah; +}; + +static struct s array[] = { + { 0 } +}; + +void +foo (struct s *p) +{ + unsigned int n = 1; + struct s *q = &array[n]; + while (p < q) + p++; +} diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index cf307593b3ce..b4251d6f1e3d 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -3184,9 +3184,13 @@ handle_ptr_arith (VEC (ce_s, heap) *lhsc, tree expr) if (c2->type == ADDRESSOF && rhsoffset != 0) { varinfo_t temp = get_varinfo (c2->var); - - gcc_assert (first_vi_for_offset (temp, rhsoffset) != NULL); - c2->var = first_vi_for_offset (temp, rhsoffset)->id; + + /* An access one after the end of an array is valid, + so simply punt on accesses we cannot resolve. */ + temp = first_vi_for_offset (temp, rhsoffset); + if (temp == NULL) + continue; + c2->var = temp->id; c2->offset = 0; } else