From f432a594fe6d3a0de1330ba69200d158e6248083 Mon Sep 17 00:00:00 2001 From: Martin Uecker Date: Thu, 2 Nov 2023 13:12:15 +0100 Subject: c: Add missing conditions in Walloc-size to avoid ICEs [PR112347] Fix ICE because of forgotten checks for pointers to void and incomplete arrays. Committed as obvious. PR c/112347 gcc/c: * c-typeck.cc (convert_for_assignment): Add missing check. gcc/testsuite: * gcc.dg/Walloc-size-3.c: New test. --- gcc/c/c-typeck.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/c') diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 16fadfb..bdd57aa 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -7367,6 +7367,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, idx = TREE_INT_CST_LOW (TREE_VALUE (TREE_CHAIN (args))) - 1; tree arg = CALL_EXPR_ARG (rhs, idx); if (TREE_CODE (arg) == INTEGER_CST + && !VOID_TYPE_P (ttl) && TYPE_SIZE_UNIT (ttl) && INTEGER_CST == TREE_CODE (TYPE_SIZE_UNIT (ttl)) && tree_int_cst_lt (arg, TYPE_SIZE_UNIT (ttl))) warning_at (location, OPT_Walloc_size, "allocation of " -- cgit v1.1