From 9ef2eff0d40fb59ee7538148fc8eb25088777297 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 22 Sep 2016 12:16:42 +0000 Subject: [PATCH] re PR tree-optimization/77697 (suspicious code in tree-ssa-forwprop.c) 2016-09-22 Richard Biener PR middle-end/77697 * gimple-fold.c (fold_array_ctor_reference): Turn asserts into fold fails. From-SVN: r240353 --- gcc/ChangeLog | 6 ++++++ gcc/gimple-fold.c | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3bd4139b3b5..c2b4470aef1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-09-22 Richard Biener + + PR middle-end/77697 + * gimple-fold.c (fold_array_ctor_reference): Turn asserts into + fold fails. + 2016-09-22 Richard Biener PR middle-end/77677 diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index addabb745ef..23e4516e020 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -5647,14 +5647,15 @@ fold_array_ctor_reference (tree type, tree ctor, if (domain_type && TYPE_MIN_VALUE (domain_type)) { /* Static constructors for variably sized objects makes no sense. */ - gcc_assert (TREE_CODE (TYPE_MIN_VALUE (domain_type)) == INTEGER_CST); + if (TREE_CODE (TYPE_MIN_VALUE (domain_type)) != INTEGER_CST) + return NULL_TREE; low_bound = wi::to_offset (TYPE_MIN_VALUE (domain_type)); } else low_bound = 0; /* Static constructors for variably sized objects makes no sense. */ - gcc_assert (TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (ctor)))) - == INTEGER_CST); + if (TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (ctor)))) != INTEGER_CST) + return NULL_TREE; elt_size = wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (ctor)))); /* We can handle only constantly sized accesses that are known to not -- 2.30.2