From 12ead254ee6dbb32760593207417ca2ebcc2ef59 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 27 Apr 2017 12:34:45 +0000 Subject: [PATCH] re PR middle-end/80533 (Alias analysis of zero length array does not recognize accesses beyond end of array) 2017-04-27 Richard Biener PR middle-end/80533 * emit-rtl.c (set_mem_attributes_minus_bitpos): When stripping ARRAY_REFs from MEM_EXPR make sure we're not keeping a reference to a trailing array. From-SVN: r247327 --- gcc/ChangeLog | 7 +++++++ gcc/emit-rtl.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 44580fc15e2..ac9a03c8307 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-04-27 Richard Biener + + PR middle-end/80533 + * emit-rtl.c (set_mem_attributes_minus_bitpos): When + stripping ARRAY_REFs from MEM_EXPR make sure we're not + keeping a reference to a trailing array. + 2017-04-27 Richard Biener PR middle-end/80539 diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 0d25d4ec17e..d7aba8864be 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -1954,7 +1954,10 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp, while (TREE_CODE (t2) == ARRAY_REF); if (DECL_P (t2) - || TREE_CODE (t2) == COMPONENT_REF) + || (TREE_CODE (t2) == COMPONENT_REF + /* For trailing arrays t2 doesn't have a size that + covers all valid accesses. */ + && ! array_at_struct_end_p (t, false))) { attrs.expr = t2; attrs.offset_known_p = false; -- 2.30.2