The following properly checks tree_fits_poly_int64_p before converting
a size to a poly_int64.
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.
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))
{