From: Richard Biener Date: Thu, 7 Apr 2022 09:59:04 +0000 (+0200) Subject: tree-optimization/99121 - avoid ICEing for non-constant sizes X-Git-Tag: releases/gcc-11.3.0~106 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4662984506b774213df9c4429d2c59664bb09adc;p=thirdparty%2Fgcc.git tree-optimization/99121 - avoid ICEing for non-constant sizes The following is a simple fix to avoid ICEing on non-constant sizes of ARRAY_REFs instead of backporting too intrusive changes done on trunk. 2022-04-07 Richard Biener PR tree-optimization/99121 * gimple-array-bounds.cc (array_bounds_checker::check_mem_ref): Bail out for non-constant type size. --- diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc index 199d9f5d2161..b11795186512 100644 --- a/gcc/gimple-array-bounds.cc +++ b/gcc/gimple-array-bounds.cc @@ -607,6 +607,8 @@ array_bounds_checker::check_mem_ref (location_t location, tree ref, if (TREE_CODE (reftype) == ARRAY_TYPE) { + if (TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (reftype))) != INTEGER_CST) + return false; /* Set to the size of the array element (and adjust below). */ eltsize = wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (reftype))); /* Use log2 of size to convert the array byte size in to its