public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/107898 - ICE with -Walloca-larger-than
@ 2022-11-29  9:25 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-11-29  9:25 UTC (permalink / raw)
  To: gcc-patches

The following avoids ICEing with a mismatched prototype for alloca
and -Walloca-larger-than using irange for checks which doesn't
like mismatched types.

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

	PR tree-optimization/107898
	* gimple-ssa-warn-alloca.cc (alloca_call_type): Check
	the type of the alloca argument is compatible with size_t
	before querying ranges.
---
 gcc/gimple-ssa-warn-alloca.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/gimple-ssa-warn-alloca.cc b/gcc/gimple-ssa-warn-alloca.cc
index 83a241a3a4b..dcc62ca77bf 100644
--- a/gcc/gimple-ssa-warn-alloca.cc
+++ b/gcc/gimple-ssa-warn-alloca.cc
@@ -217,6 +217,7 @@ alloca_call_type (gimple *stmt, bool is_vla)
   int_range_max r;
   if (warn_limit_specified_p (is_vla)
       && TREE_CODE (len) == SSA_NAME
+      && types_compatible_p (TREE_TYPE (len), size_type_node)
       && get_range_query (cfun)->range_of_expr (r, len, stmt)
       && !r.varying_p ())
     {
-- 
2.35.3

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

only message in thread, other threads:[~2022-11-29  9:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29  9:25 [PATCH] tree-optimization/107898 - ICE with -Walloca-larger-than 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).