diff options
author | Richard Biener <rguenth@gcc.gnu.org> | 2010-07-15 11:17:37 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-07-15 11:17:37 +0000 |
commit | 0ba0772ba46e80a54bd712cada5b9395fce28399 (patch) | |
tree | 2df76aff858642dd504876b611f466bb766c2ad0 /gcc | |
parent | 02ee7bea62cc77ed1ee6aa94970cc576af7d3903 (diff) | |
download | gcc-0ba0772ba46e80a54bd712cada5b9395fce28399.zip gcc-0ba0772ba46e80a54bd712cada5b9395fce28399.tar.gz gcc-0ba0772ba46e80a54bd712cada5b9395fce28399.tar.bz2 |
re PR tree-optimization/44946 (ICE: in get_constraint_for_component_ref, at tree-ssa-structalias.c:3184)
2010-07-15 Richard Guenther <rguenther@suse.de>
PR tree-optimization/44946
* tree-ssa-structalias.c (get_constraint_for_component_ref): Deal
with accessing only padding properly.
* gcc.c-torture/compile/pr44946.c: New testcase.
From-SVN: r162216
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr44946.c | 27 | ||||
-rw-r--r-- | gcc/tree-ssa-structalias.c | 12 |
4 files changed, 49 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d608241..3443ac8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,7 +1,13 @@ +2010-07-15 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/44946 + * tree-ssa-structalias.c (get_constraint_for_component_ref): Deal + with accessing only padding properly. + 2010-07-15 Jan Hubicka <jh@suse.cz> - * ipa.c (function_and_variable_visibility): Variables marked as used should - not be localized. + * ipa.c (function_and_variable_visibility): Variables marked as used + should not be localized. 2010-07-15 Jan Hubicka <jh@suse.cz> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bb7b4b0..47d81f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-07-15 Richard Guenther <rguenther@suse.de> + + PR tree-optimization/44946 + * gcc.c-torture/compile/pr44946.c: New testcase. + 2010-07-15 Jakub Jelinek <jakub@redhat.com> PR fortran/40206 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr44946.c b/gcc/testsuite/gcc.c-torture/compile/pr44946.c new file mode 100644 index 0000000..7b23012 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr44946.c @@ -0,0 +1,27 @@ +struct A +{ + int i; + long l; +}; + +struct B +{ + int i; +}; + +struct C +{ + int i; + struct B b; +}; + +struct B foo (struct A a) +{ + struct C *c = (struct C *) &a; + return c->b; +} +void bar (struct A a, struct B b) +{ + struct C *c = (struct C *) &a; + c->b = b; +} diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 68e0cac..417671c 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -3177,13 +3177,19 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results, cexpr.var = curr->id; VEC_safe_push (ce_s, heap, *results, &cexpr); } - else + else if (VEC_length (ce_s, *results) == 0) /* Assert that we found *some* field there. The user couldn't be accessing *only* padding. */ /* Still the user could access one past the end of an array embedded in a struct resulting in accessing *only* padding. */ - gcc_assert (VEC_length (ce_s, *results) >= 1 - || ref_contains_array_ref (orig_t)); + /* Or accessing only padding via type-punning to a type + that has a filed just in padding space. */ + { + cexpr.type = SCALAR; + cexpr.var = anything_id; + cexpr.offset = 0; + VEC_safe_push (ce_s, heap, *results, &cexpr); + } } else if (bitmaxsize == 0) { |