From 7bfcb402eab7dbcf0108c5b9682a8b409fad4359 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 26 Sep 2007 13:32:27 +0100 Subject: re PR c/25309 (ICE on initialization of a huge array) PR c/25309 * c-common.c (complete_array_type): Diagnose too-large arrays and set type to error_mark_node. testsuite: * gcc.dg/large-size-array-2.c: Expect diagnostic for too-large array. * gcc.dg/large-size-array-4.c: New. Copy of large-size-array-2.c without -O2. From-SVN: r128811 --- gcc/c-common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/c-common.c') diff --git a/gcc/c-common.c b/gcc/c-common.c index 8ebc920..bdb8d80 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -7049,6 +7049,16 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) else type = c_build_qualified_type (main_type, quals); + if (COMPLETE_TYPE_P (type) + && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST + && TREE_OVERFLOW (TYPE_SIZE_UNIT (type))) + { + error ("size of array is too large"); + /* If we proceed with the array type as it is, we'll eventually + crash in tree_low_cst(). */ + type = error_mark_node; + } + *ptype = type; return failure; } -- cgit v1.1