From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128902 invoked by alias); 16 Mar 2018 14:49:20 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 128876 invoked by uid 89); 16 Mar 2018 14:49:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=HContent-Transfer-Encoding:8bit, sum X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Mar 2018 14:49:17 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id w2GEnFQn085470 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 16 Mar 2018 07:49:15 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id w2GEnFlH085469; Fri, 16 Mar 2018 07:49:15 -0700 (PDT) (envelope-from sgk) Date: Fri, 16 Mar 2018 14:49:00 -0000 From: Steve Kargl To: "Dominique =?iso-8859-1?Q?d'Humi=E8res?=" Cc: gfortran Subject: Re: [PATCH] PR fortran/69395 -- don't exceed max allowed array dimensions Message-ID: <20180316144914.GA85401@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu References: <5260C3DF-899C-4A9D-A8F9-F076E5ACC33A@lps.ens.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5260C3DF-899C-4A9D-A8F9-F076E5ACC33A@lps.ens.fr> User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00087.txt.bz2 On Fri, Mar 16, 2018 at 11:46:24AM +0100, Dominique d'Humières wrote: > > With one of my variants I see > > pr69395_3_db.f90:2:63: > > real, dimension(1,2,1,2,1,2,1,2), codimension[1,2,1,2,1,2,*] :: z > 1 > Error: Sum of array rank 8 and corank 7 at (1) exceeds maximum allowed dimensions of 15 > > Is this expected or should > > if (j >= GFC_MAX_DIMENSIONS) > > be replaced with > > if (j > GFC_MAX_DIMENSIONS) > > (twice)? > Well, the above is legal, so there is probably an off-by-one issue. Note, that there are a few other places where "rank + corank >= GFC_MAX_DIMENSIONS" checks are done. I simply copied a nearby if (). array.c: if (as->rank + as->corank >= GFC_MAX_DIMENSIONS) array.c: if (as->rank >= GFC_MAX_DIMENSIONS) array.c: if (as->rank + as->corank >= GFC_MAX_DIMENSIONS) check.c: if (source->rank >= GFC_MAX_DIMENSIONS) mine decl.c: if (j >= GFC_MAX_DIMENSIONS) mine decl.c: if (j >= GFC_MAX_DIMENSIONS) decl.c: if (to->rank + to->corank >= GFC_MAX_DIMENSIONS) My checks are breaking out of existing for-loops and protecting against as->lower[j] = .... as->upper[j] = .... where gfortran.h: struct gfc_expr *lower[GFC_MAX_DIMENSIONS], *upper[GFC_MAX_DIMENSIONS]; I'll take a look at the code tomorrow. -- Steve