public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][GCC11] tree-optimization/99121 - avoid ICEing for non-constant sizes
@ 2022-04-07 10:01 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-04-07 10:01 UTC (permalink / raw)
  To: gcc-patches

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.

Bootstrap / regtest pending on x86_64-unknown-linux-gnu.

2022-04-07  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/99121
	* gimple-array-bounds.cc (array_bounds_checker::check_mem_ref):
	Bail out for non-constant type size.
---
 gcc/gimple-array-bounds.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/gimple-array-bounds.cc b/gcc/gimple-array-bounds.cc
index 199d9f5d216..b1179518651 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
-- 
2.34.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-07 10:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 10:01 [PATCH][GCC11] tree-optimization/99121 - avoid ICEing for non-constant sizes Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).