tree-optimization/105232 - handle overly large sizes in component_ref_size

Message ID 20220412085322.C193513780@imap2.suse-dmz.suse.de
State Committed
Commit 1bd96873cf73c4f59de48e9bc0d17a498f1ede04
Headers
Series tree-optimization/105232 - handle overly large sizes in component_ref_size |

Commit Message

Richard Biener April 12, 2022, 8:53 a.m. UTC
  The following properly checks tree_fits_poly_int64_p before converting
a size to a poly_int64.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

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

	PR tree-optimization/105232
	* tree.cc (component_ref_size): Bail out for too large
	or non-constant sizes.
---
 gcc/tree.cc | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/gcc/tree.cc b/gcc/tree.cc
index 8f83ea1aae3..609f0b4569a 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -12961,6 +12961,8 @@  component_ref_size (tree ref, special_array_member *sam /* = NULL */)
      to struct types with flexible array members.  */
   if (memsize)
     {
+      if (!tree_fits_poly_int64_p (memsize))
+	return NULL_TREE;
       poly_int64 memsz64 = memsize ? tree_to_poly_int64 (memsize) : 0;
       if (known_lt (baseoff, memsz64))
 	{