From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16192 invoked by alias); 9 Apr 2011 15:45:43 -0000 Received: (qmail 16184 invoked by uid 22791); 9 Apr 2011 15:45:42 -0000 X-SWARE-Spam-Status: No, hits=0.2 required=5.0 tests=AWL,BAYES_50,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,FSL_RU_URL,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 09 Apr 2011 15:45:37 +0000 Received: by wwf26 with SMTP id 26so5177541wwf.8 for ; Sat, 09 Apr 2011 08:45:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.150.207 with SMTP id z15mr3448968wbv.149.1302363936618; Sat, 09 Apr 2011 08:45:36 -0700 (PDT) Received: by 10.227.0.140 with HTTP; Sat, 9 Apr 2011 08:45:36 -0700 (PDT) In-Reply-To: <4DA04180.9040404@free.fr> References: <4DA04180.9040404@free.fr> Date: Sat, 09 Apr 2011 15:45:00 -0000 Message-ID: Subject: Re: [PATCH] Do not crash in array_type_nelts if TYPE_MIN_VALUE is null From: Richard Guenther To: Duncan Sands Cc: gcc-patches Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg00690.txt.bz2 On Sat, Apr 9, 2011 at 1:22 PM, Duncan Sands wrote: > I recently changed the dragonegg plugin to use array_type_nelts, and just > got > sent a Fortran testcase that shows that array_type_nelts can crash on arr= ay > types coming from Fortran. =A0The array type in question has TYPE_DOMAIN = set, > with TYPE_MIN_VALUE equal to 1 (because the array is indexed from 1) but = no > TYPE_MAX_VALUE (because the array length is not known). =A0Here's a patch= that > fixes array_type_nelts. =A0Unfortunately I don't have a testcase that sho= ws > the > issue without the use of the dragonegg plugin. > > Tested by bootstrapping mainline and running the testsuite with gcc-4.5. = =A0OK > to > apply on mainline and the 4.5 and 4.6 branches? Ok. Thanks, Richard. > Ciao, Duncan. > > Index: gcc/tree.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/tree.c =A0(revision 172166) > +++ gcc/tree.c =A0(working copy) > @@ -2462,6 +2462,10 @@ > =A0 min =3D TYPE_MIN_VALUE (index_type); > =A0 max =3D TYPE_MAX_VALUE (index_type); > > + =A0/* TYPE_MAX_VALUE may not be set if the array has unknown length. = =A0*/ > + =A0if (!max) > + =A0 =A0return error_mark_node; > + > =A0 return (integer_zerop (min) > =A0 =A0 =A0 =A0 =A0? max > =A0 =A0 =A0 =A0 =A0: fold_build2 (MINUS_EXPR, TREE_TYPE (max), max, min)); > Index: gcc/ChangeLog > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gcc/ChangeLog =A0 =A0 =A0 (revision 172166) > +++ gcc/ChangeLog =A0 =A0 =A0 (working copy) > @@ -1,3 +1,7 @@ > +2011-04-08 =A0Duncan Sands =A0 > + > + =A0 =A0 =A0 * tree.c (array_type_nelts): Bail out if TYPE_MAX_VALUE not= set. > + > =A02011-04-08 =A0Anatoly Sokolov =A0 > > =A0 =A0 =A0 =A0* doc/tm.texi.in (ASM_OUTPUT_BSS): Remove documentation. >