From: Duncan Sands Date: Sat, 9 Apr 2011 16:21:20 +0000 (+0200) Subject: Bail out rather than crashing in array_type_nelts if TYPE_MAX_VALUE is null. X-Git-Tag: releases/gcc-4.5.3~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a16beeae660614fd33028aa94f4c2235539823b3;p=thirdparty%2Fgcc.git Bail out rather than crashing in array_type_nelts if TYPE_MAX_VALUE is null. From-SVN: r172228 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b8d07e93ccf2..fb4d53ff174c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2011-04-09 Duncan Sands + + * tree.c (array_type_nelts): Bail out if TYPE_MAX_VALUE not set. + 2011-04-07 Uros Bizjak * config/i386/sse.md (avx_cmps3): Add diff --git a/gcc/tree.c b/gcc/tree.c index 4b1bfac42ae9..7bf2e3e086b4 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -2337,6 +2337,10 @@ array_type_nelts (const_tree type) min = TYPE_MIN_VALUE (index_type); max = TYPE_MAX_VALUE (index_type); + /* TYPE_MAX_VALUE may not be set if the array has unknown length. */ + if (!max) + return error_mark_node; + return (integer_zerop (min) ? max : fold_build2 (MINUS_EXPR, TREE_TYPE (max), max, min));