From patchwork Sun Jul 30 18:55:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 795417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-459318-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="fpRGbu2T"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xLBdY36hZz9s81 for ; Mon, 31 Jul 2017 04:56:47 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=KcgHejs6Hixll24aXT93BQx+qyQN5P1ENGKd8+40DoixVC6lXq NVDLJgJdykeWYC74oKTKTdckhQw/Rn05bXLUq4rPL1+ppuFkFnk7DRJqbGLsGU5b IKHuF1RgrX5Q3Ek1KPNfcMTeXQ1PxCKCtOT2/d4zyimJWlePUmUH2BIdc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=tDLNGpSb9KvpJaHmJeBho1yIlbs=; b=fpRGbu2TjpIRlwYPEPKv xgHtCzvvZZDtDkmKjnvgPQi+j3lGyYkhZDH0sMjiXDXHGrK4ldsdwXscVPA/fBM/ kvGnBd8r99NhgvnuBm/VPbunXqHZnzED8k4M0EWaOxKVyr7dX2FhltAzqr+mJ5bB JyjOmaXaZaNWZ6vIW9El60w= Received: (qmail 24722 invoked by alias); 30 Jul 2017 18:55:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 24675 invoked by uid 89); 30 Jul 2017 18:55:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=4456, PRODUCT, norm X-Spam-User: qpsmtpd, 2 recipients X-HELO: cc-smtpout2.netcologne.de Received: from cc-smtpout2.netcologne.de (HELO cc-smtpout2.netcologne.de) (89.1.8.212) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 30 Jul 2017 18:55:26 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id EBC8912555; Sun, 30 Jul 2017 20:55:22 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id D983911DF4; Sun, 30 Jul 2017 20:55:22 +0200 (CEST) Received: from [78.35.135.193] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.1.9) (envelope-from ) id 597e2b9a-0242-7f0000012729-7f000001d06a-1 for ; Sun, 30 Jul 2017 20:55:22 +0200 Received: from [192.168.178.20] (xdsl-78-35-135-193.netcologne.de [78.35.135.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Sun, 30 Jul 2017 20:55:17 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [ patch, libfortran] Fix PR 81581 Message-ID: Date: Sun, 30 Jul 2017 20:55:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Hello world, the attached patch performs a runtime-check for the dim arguments for transformational intrinsic functions. I debated with myself a bit if I should make this depend on bounds checking, but I finally decided against it. The tests performed are extemely cheap, the values are still in registers, so any runtime overhead should be small. By contrast, loading something from an external structure is probably more expensive (but I didn't bother actually check). While visiting the code, I also took the opportunity to make the rank and dim variables in the 'm' class of functions to index_type, to make their use consistent. Regarding the test case names, I was unable to resist. Regression-tested. OK for trunk? Thomas 2017-07-30 Thomas Koenig PR fortran/81581 * m4/ifuntion.m4 (name`'rtype_qual`_'atype_code): Perform check for dim. (`m'name`'rtype_qual`_'atype_code): Likewise. Change type of rank and tim to index_type. (`s'name`'rtype_qual`_'atype_code): Perform check for dim. * generated/iall_i16.c: Regenerated. * generated/iall_i1.c: Regenerated. * generated/iall_i2.c: Regenerated. * generated/iall_i4.c: Regenerated. * generated/iall_i8.c: Regenerated. * generated/iany_i16.c: Regenerated. * generated/iany_i1.c: Regenerated. * generated/iany_i2.c: Regenerated. * generated/iany_i4.c: Regenerated. * generated/iany_i8.c: Regenerated. * generated/iparity_i16.c: Regenerated. * generated/iparity_i1.c: Regenerated. * generated/iparity_i2.c: Regenerated. * generated/iparity_i4.c: Regenerated. * generated/iparity_i8.c: Regenerated. * generated/maxloc1_16_i16.c: Regenerated. * generated/maxloc1_16_i1.c: Regenerated. * generated/maxloc1_16_i2.c: Regenerated. * generated/maxloc1_16_i4.c: Regenerated. * generated/maxloc1_16_i8.c: Regenerated. * generated/maxloc1_16_r10.c: Regenerated. * generated/maxloc1_16_r16.c: Regenerated. * generated/maxloc1_16_r4.c: Regenerated. * generated/maxloc1_16_r8.c: Regenerated. * generated/maxloc1_4_i16.c: Regenerated. * generated/maxloc1_4_i1.c: Regenerated. * generated/maxloc1_4_i2.c: Regenerated. * generated/maxloc1_4_i4.c: Regenerated. * generated/maxloc1_4_i8.c: Regenerated. * generated/maxloc1_4_r10.c: Regenerated. * generated/maxloc1_4_r16.c: Regenerated. * generated/maxloc1_4_r4.c: Regenerated. * generated/maxloc1_4_r8.c: Regenerated. * generated/maxloc1_8_i16.c: Regenerated. * generated/maxloc1_8_i1.c: Regenerated. * generated/maxloc1_8_i2.c: Regenerated. * generated/maxloc1_8_i4.c: Regenerated. * generated/maxloc1_8_i8.c: Regenerated. * generated/maxloc1_8_r10.c: Regenerated. * generated/maxloc1_8_r16.c: Regenerated. * generated/maxloc1_8_r4.c: Regenerated. * generated/maxloc1_8_r8.c: Regenerated. * generated/maxval_i16.c: Regenerated. * generated/maxval_i1.c: Regenerated. * generated/maxval_i2.c: Regenerated. * generated/maxval_i4.c: Regenerated. * generated/maxval_i8.c: Regenerated. * generated/maxval_r10.c: Regenerated. * generated/maxval_r16.c: Regenerated. * generated/maxval_r4.c: Regenerated. * generated/maxval_r8.c: Regenerated. * generated/minloc1_16_i16.c: Regenerated. * generated/minloc1_16_i1.c: Regenerated. * generated/minloc1_16_i2.c: Regenerated. * generated/minloc1_16_i4.c: Regenerated. * generated/minloc1_16_i8.c: Regenerated. * generated/minloc1_16_r10.c: Regenerated. * generated/minloc1_16_r16.c: Regenerated. * generated/minloc1_16_r4.c: Regenerated. * generated/minloc1_16_r8.c: Regenerated. * generated/minloc1_4_i16.c: Regenerated. * generated/minloc1_4_i1.c: Regenerated. * generated/minloc1_4_i2.c: Regenerated. * generated/minloc1_4_i4.c: Regenerated. * generated/minloc1_4_i8.c: Regenerated. * generated/minloc1_4_r10.c: Regenerated. * generated/minloc1_4_r16.c: Regenerated. * generated/minloc1_4_r4.c: Regenerated. * generated/minloc1_4_r8.c: Regenerated. * generated/minloc1_8_i16.c: Regenerated. * generated/minloc1_8_i1.c: Regenerated. * generated/minloc1_8_i2.c: Regenerated. * generated/minloc1_8_i4.c: Regenerated. * generated/minloc1_8_i8.c: Regenerated. * generated/minloc1_8_r10.c: Regenerated. * generated/minloc1_8_r16.c: Regenerated. * generated/minloc1_8_r4.c: Regenerated. * generated/minloc1_8_r8.c: Regenerated. * generated/minval_i16.c: Regenerated. * generated/minval_i1.c: Regenerated. * generated/minval_i2.c: Regenerated. * generated/minval_i4.c: Regenerated. * generated/minval_i8.c: Regenerated. * generated/minval_r10.c: Regenerated. * generated/minval_r16.c: Regenerated. * generated/minval_r4.c: Regenerated. * generated/minval_r8.c: Regenerated. * generated/norm2_r10.c: Regenerated. * generated/norm2_r16.c: Regenerated. * generated/norm2_r4.c: Regenerated. * generated/norm2_r8.c: Regenerated. * generated/parity_l16.c: Regenerated. * generated/parity_l1.c: Regenerated. * generated/parity_l2.c: Regenerated. * generated/parity_l4.c: Regenerated. * generated/parity_l8.c: Regenerated. * generated/product_c10.c: Regenerated. * generated/product_c16.c: Regenerated. * generated/product_c4.c: Regenerated. * generated/product_c8.c: Regenerated. * generated/product_i16.c: Regenerated. * generated/product_i1.c: Regenerated. * generated/product_i2.c: Regenerated. * generated/product_i4.c: Regenerated. * generated/product_i8.c: Regenerated. * generated/product_r10.c: Regenerated. * generated/product_r16.c: Regenerated. * generated/product_r4.c: Regenerated. * generated/product_r8.c: Regenerated. * generated/sum_c10.c: Regenerated. * generated/sum_c16.c: Regenerated. * generated/sum_c4.c: Regenerated. * generated/sum_c8.c: Regenerated. * generated/sum_i16.c: Regenerated. * generated/sum_i1.c: Regenerated. * generated/sum_i2.c: Regenerated. * generated/sum_i4.c: Regenerated. * generated/sum_i8.c: Regenerated. * generated/sum_r10.c: Regenerated. * generated/sum_r16.c: Regenerated. * generated/sum_r4.c: Regenerated. * generated/sum_r8.c: Regenerated. 2017-07-30 Thomas Koenig PR fortran/81581 * gfortran.dg/dim_sum_1.f90: New test case. * gfortran.dg/dim_sum_2.f90: New test case. * gfortran.dg/dim_sum_3.f90: New test case. Index: m4/ifunction.m4 =================================================================== --- m4/ifunction.m4 (Revision 250720) +++ m4/ifunction.m4 (Arbeitskopie) @@ -45,6 +45,13 @@ name`'rtype_qual`_'atype_code (rtype * const restr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in u_name intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -193,8 +200,8 @@ void rtype_name * restrict dest; const atype_name * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -204,6 +211,14 @@ void dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in u_name intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -380,6 +395,13 @@ void dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in u_name intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iall_i1.c =================================================================== --- generated/iall_i1.c (Revision 250720) +++ generated/iall_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ iall_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miall_i1 (gfc_array_i1 * const restrict retarray, GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miall_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siall_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iall_i16.c =================================================================== --- generated/iall_i16.c (Revision 250720) +++ generated/iall_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ iall_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miall_i16 (gfc_array_i16 * const restrict retarray GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miall_i16 (gfc_array_i16 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siall_i16 (gfc_array_i16 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iall_i2.c =================================================================== --- generated/iall_i2.c (Revision 250720) +++ generated/iall_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ iall_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miall_i2 (gfc_array_i2 * const restrict retarray, GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miall_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siall_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iall_i4.c =================================================================== --- generated/iall_i4.c (Revision 250720) +++ generated/iall_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ iall_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miall_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miall_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siall_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iall_i8.c =================================================================== --- generated/iall_i8.c (Revision 250720) +++ generated/iall_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ iall_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miall_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miall_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siall_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IALL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iany_i1.c =================================================================== --- generated/iany_i1.c (Revision 250720) +++ generated/iany_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ iany_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miany_i1 (gfc_array_i1 * const restrict retarray, GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miany_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siany_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iany_i16.c =================================================================== --- generated/iany_i16.c (Revision 250720) +++ generated/iany_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ iany_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miany_i16 (gfc_array_i16 * const restrict retarray GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miany_i16 (gfc_array_i16 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siany_i16 (gfc_array_i16 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iany_i2.c =================================================================== --- generated/iany_i2.c (Revision 250720) +++ generated/iany_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ iany_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miany_i2 (gfc_array_i2 * const restrict retarray, GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miany_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siany_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iany_i4.c =================================================================== --- generated/iany_i4.c (Revision 250720) +++ generated/iany_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ iany_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miany_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miany_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siany_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iany_i8.c =================================================================== --- generated/iany_i8.c (Revision 250720) +++ generated/iany_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ iany_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miany_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miany_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siany_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IANY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iparity_i1.c =================================================================== --- generated/iparity_i1.c (Revision 250720) +++ generated/iparity_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ iparity_i1 (gfc_array_i1 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miparity_i1 (gfc_array_i1 * const restrict retarra GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miparity_i1 (gfc_array_i1 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siparity_i1 (gfc_array_i1 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iparity_i16.c =================================================================== --- generated/iparity_i16.c (Revision 250720) +++ generated/iparity_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ iparity_i16 (gfc_array_i16 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miparity_i16 (gfc_array_i16 * const restrict retar GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miparity_i16 (gfc_array_i16 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siparity_i16 (gfc_array_i16 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iparity_i2.c =================================================================== --- generated/iparity_i2.c (Revision 250720) +++ generated/iparity_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ iparity_i2 (gfc_array_i2 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miparity_i2 (gfc_array_i2 * const restrict retarra GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miparity_i2 (gfc_array_i2 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siparity_i2 (gfc_array_i2 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iparity_i4.c =================================================================== --- generated/iparity_i4.c (Revision 250720) +++ generated/iparity_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ iparity_i4 (gfc_array_i4 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miparity_i4 (gfc_array_i4 * const restrict retarra GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miparity_i4 (gfc_array_i4 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siparity_i4 (gfc_array_i4 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/iparity_i8.c =================================================================== --- generated/iparity_i8.c (Revision 250720) +++ generated/iparity_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ iparity_i8 (gfc_array_i8 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ miparity_i8 (gfc_array_i8 * const restrict retarra GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ miparity_i8 (gfc_array_i8 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ siparity_i8 (gfc_array_i8 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in IPARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_16_i1.c =================================================================== --- generated/maxloc1_16_i1.c (Revision 250720) +++ generated/maxloc1_16_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_16_i1 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_16_i1 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_i1 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_i1 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_16_i16.c =================================================================== --- generated/maxloc1_16_i16.c (Revision 250720) +++ generated/maxloc1_16_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_16_i16 (gfc_array_i16 * const restrict ret int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict re GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_i16 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_16_i2.c =================================================================== --- generated/maxloc1_16_i2.c (Revision 250720) +++ generated/maxloc1_16_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_16_i2 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_16_i2 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_i2 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_i2 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_16_i4.c =================================================================== --- generated/maxloc1_16_i4.c (Revision 250720) +++ generated/maxloc1_16_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_16_i4 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_i4 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_16_i8.c =================================================================== --- generated/maxloc1_16_i8.c (Revision 250720) +++ generated/maxloc1_16_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_i8 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_16_r10.c =================================================================== --- generated/maxloc1_16_r10.c (Revision 250720) +++ generated/maxloc1_16_r10.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_16_r10 (gfc_array_i16 * const restrict ret int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_16_r10 (gfc_array_i16 * const restrict re GFC_INTEGER_16 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_r10 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_r10 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_16_r16.c =================================================================== --- generated/maxloc1_16_r16.c (Revision 250720) +++ generated/maxloc1_16_r16.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_16_r16 (gfc_array_i16 * const restrict ret int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_16_r16 (gfc_array_i16 * const restrict re GFC_INTEGER_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_r16 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_r16 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_16_r4.c =================================================================== --- generated/maxloc1_16_r4.c (Revision 250720) +++ generated/maxloc1_16_r4.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_16_r4 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_16_r4 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_r4 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_r4 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_16_r8.c =================================================================== --- generated/maxloc1_16_r8.c (Revision 250720) +++ generated/maxloc1_16_r8.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_16_r8 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_16_r8 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_4_i1.c =================================================================== --- generated/maxloc1_4_i1.c (Revision 250720) +++ generated/maxloc1_4_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_4_i1 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_4_i1 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_i1 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_i1 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_4_i16.c =================================================================== --- generated/maxloc1_4_i16.c (Revision 250720) +++ generated/maxloc1_4_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict reta GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_i16 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_4_i2.c =================================================================== --- generated/maxloc1_4_i2.c (Revision 250720) +++ generated/maxloc1_4_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_4_i2 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_4_i2 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_i2 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_i2 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_4_i4.c =================================================================== --- generated/maxloc1_4_i4.c (Revision 250720) +++ generated/maxloc1_4_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_4_i4 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_i4 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_4_i8.c =================================================================== --- generated/maxloc1_4_i8.c (Revision 250720) +++ generated/maxloc1_4_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_i8 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_4_r10.c =================================================================== --- generated/maxloc1_4_r10.c (Revision 250720) +++ generated/maxloc1_4_r10.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_4_r10 (gfc_array_i4 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_4_r10 (gfc_array_i4 * const restrict reta GFC_INTEGER_4 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_r10 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_r10 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_4_r16.c =================================================================== --- generated/maxloc1_4_r16.c (Revision 250720) +++ generated/maxloc1_4_r16.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_4_r16 (gfc_array_i4 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_4_r16 (gfc_array_i4 * const restrict reta GFC_INTEGER_4 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_r16 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_r16 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_4_r4.c =================================================================== --- generated/maxloc1_4_r4.c (Revision 250720) +++ generated/maxloc1_4_r4.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_4_r4 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_4_r4 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_r4 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_r4 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_4_r8.c =================================================================== --- generated/maxloc1_4_r8.c (Revision 250720) +++ generated/maxloc1_4_r8.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_4_r8 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_4_r8 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_4_r8 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_4_r8 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_8_i1.c =================================================================== --- generated/maxloc1_8_i1.c (Revision 250720) +++ generated/maxloc1_8_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_8_i1 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_8_i1 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_i1 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_i1 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_8_i16.c =================================================================== --- generated/maxloc1_8_i16.c (Revision 250720) +++ generated/maxloc1_8_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict reta GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_i16 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_8_i2.c =================================================================== --- generated/maxloc1_8_i2.c (Revision 250720) +++ generated/maxloc1_8_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_8_i2 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_8_i2 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_i2 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_i2 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_8_i4.c =================================================================== --- generated/maxloc1_8_i4.c (Revision 250720) +++ generated/maxloc1_8_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_8_i4 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_i4 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_8_i8.c =================================================================== --- generated/maxloc1_8_i8.c (Revision 250720) +++ generated/maxloc1_8_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_i8 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_8_r10.c =================================================================== --- generated/maxloc1_8_r10.c (Revision 250720) +++ generated/maxloc1_8_r10.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_8_r10 (gfc_array_i8 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_8_r10 (gfc_array_i8 * const restrict reta GFC_INTEGER_8 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_r10 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_r10 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_8_r16.c =================================================================== --- generated/maxloc1_8_r16.c (Revision 250720) +++ generated/maxloc1_8_r16.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_8_r16 (gfc_array_i8 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_8_r16 (gfc_array_i8 * const restrict reta GFC_INTEGER_8 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_r16 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_r16 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_8_r4.c =================================================================== --- generated/maxloc1_8_r4.c (Revision 250720) +++ generated/maxloc1_8_r4.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_8_r4 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_8_r4 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_r4 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_r4 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxloc1_8_r8.c =================================================================== --- generated/maxloc1_8_r8.c (Revision 250720) +++ generated/maxloc1_8_r8.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxloc1_8_r8 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mmaxloc1_8_r8 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mmaxloc1_8_r8 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ smaxloc1_8_r8 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxval_i1.c =================================================================== --- generated/maxval_i1.c (Revision 250720) +++ generated/maxval_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxval_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mmaxval_i1 (gfc_array_i1 * const restrict retarray GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_i1 (gfc_array_i1 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_i1 (gfc_array_i1 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxval_i16.c =================================================================== --- generated/maxval_i16.c (Revision 250720) +++ generated/maxval_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxval_i16 (gfc_array_i16 * const restrict retarra int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mmaxval_i16 (gfc_array_i16 * const restrict retarr GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_i16 (gfc_array_i16 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_i16 (gfc_array_i16 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxval_i2.c =================================================================== --- generated/maxval_i2.c (Revision 250720) +++ generated/maxval_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxval_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mmaxval_i2 (gfc_array_i2 * const restrict retarray GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_i2 (gfc_array_i2 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_i2 (gfc_array_i2 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxval_i4.c =================================================================== --- generated/maxval_i4.c (Revision 250720) +++ generated/maxval_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxval_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_i4 (gfc_array_i4 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxval_i8.c =================================================================== --- generated/maxval_i8.c (Revision 250720) +++ generated/maxval_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxval_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mmaxval_i8 (gfc_array_i8 * const restrict retarray GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_i8 (gfc_array_i8 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_i8 (gfc_array_i8 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxval_r10.c =================================================================== --- generated/maxval_r10.c (Revision 250720) +++ generated/maxval_r10.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxval_r10 (gfc_array_r10 * const restrict retarra int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mmaxval_r10 (gfc_array_r10 * const restrict retarr GFC_REAL_10 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_r10 (gfc_array_r10 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_r10 (gfc_array_r10 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxval_r16.c =================================================================== --- generated/maxval_r16.c (Revision 250720) +++ generated/maxval_r16.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxval_r16 (gfc_array_r16 * const restrict retarra int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mmaxval_r16 (gfc_array_r16 * const restrict retarr GFC_REAL_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_r16 (gfc_array_r16 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_r16 (gfc_array_r16 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxval_r4.c =================================================================== --- generated/maxval_r4.c (Revision 250720) +++ generated/maxval_r4.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxval_r4 (gfc_array_r4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mmaxval_r4 (gfc_array_r4 * const restrict retarray GFC_REAL_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_r4 (gfc_array_r4 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_r4 (gfc_array_r4 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/maxval_r8.c =================================================================== --- generated/maxval_r8.c (Revision 250720) +++ generated/maxval_r8.c (Arbeitskopie) @@ -52,9 +52,16 @@ maxval_r8 (gfc_array_r8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mmaxval_r8 (gfc_array_r8 * const restrict retarray GFC_REAL_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mmaxval_r8 (gfc_array_r8 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ smaxval_r8 (gfc_array_r8 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MAXVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_16_i1.c =================================================================== --- generated/minloc1_16_i1.c (Revision 250720) +++ generated/minloc1_16_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_16_i1 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_16_i1 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_i1 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_i1 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_16_i16.c =================================================================== --- generated/minloc1_16_i16.c (Revision 250720) +++ generated/minloc1_16_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_16_i16 (gfc_array_i16 * const restrict ret int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_16_i16 (gfc_array_i16 * const restrict re GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_i16 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_i16 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_16_i2.c =================================================================== --- generated/minloc1_16_i2.c (Revision 250720) +++ generated/minloc1_16_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_16_i2 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_16_i2 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_i2 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_i2 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_16_i4.c =================================================================== --- generated/minloc1_16_i4.c (Revision 250720) +++ generated/minloc1_16_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_16_i4 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_16_i4 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_i4 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_i4 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_16_i8.c =================================================================== --- generated/minloc1_16_i8.c (Revision 250720) +++ generated/minloc1_16_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_16_i8 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_16_i8 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_i8 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_i8 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_16_r10.c =================================================================== --- generated/minloc1_16_r10.c (Revision 250720) +++ generated/minloc1_16_r10.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_16_r10 (gfc_array_i16 * const restrict ret int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_16_r10 (gfc_array_i16 * const restrict re GFC_INTEGER_16 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_r10 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_r10 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_16_r16.c =================================================================== --- generated/minloc1_16_r16.c (Revision 250720) +++ generated/minloc1_16_r16.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_16_r16 (gfc_array_i16 * const restrict ret int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_16_r16 (gfc_array_i16 * const restrict re GFC_INTEGER_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_r16 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_r16 (gfc_array_i16 * const restrict re dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_16_r4.c =================================================================== --- generated/minloc1_16_r4.c (Revision 250720) +++ generated/minloc1_16_r4.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_16_r4 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_16_r4 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_r4 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_r4 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_16_r8.c =================================================================== --- generated/minloc1_16_r8.c (Revision 250720) +++ generated/minloc1_16_r8.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_16_r8 (gfc_array_i16 * const restrict reta int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_16_r8 (gfc_array_i16 * const restrict ret GFC_INTEGER_16 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_16_r8 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_16_r8 (gfc_array_i16 * const restrict ret dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_4_i1.c =================================================================== --- generated/minloc1_4_i1.c (Revision 250720) +++ generated/minloc1_4_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_4_i1 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_4_i1 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_i1 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_i1 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_4_i16.c =================================================================== --- generated/minloc1_4_i16.c (Revision 250720) +++ generated/minloc1_4_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_4_i16 (gfc_array_i4 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_4_i16 (gfc_array_i4 * const restrict reta GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_i16 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_i16 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_4_i2.c =================================================================== --- generated/minloc1_4_i2.c (Revision 250720) +++ generated/minloc1_4_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_4_i2 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_4_i2 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_i2 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_i2 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_4_i4.c =================================================================== --- generated/minloc1_4_i4.c (Revision 250720) +++ generated/minloc1_4_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_4_i4 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_4_i4 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_i4 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_i4 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_4_i8.c =================================================================== --- generated/minloc1_4_i8.c (Revision 250720) +++ generated/minloc1_4_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_4_i8 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_4_i8 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_i8 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_i8 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_4_r10.c =================================================================== --- generated/minloc1_4_r10.c (Revision 250720) +++ generated/minloc1_4_r10.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_4_r10 (gfc_array_i4 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_4_r10 (gfc_array_i4 * const restrict reta GFC_INTEGER_4 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_r10 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_r10 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_4_r16.c =================================================================== --- generated/minloc1_4_r16.c (Revision 250720) +++ generated/minloc1_4_r16.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_4_r16 (gfc_array_i4 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_4_r16 (gfc_array_i4 * const restrict reta GFC_INTEGER_4 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_r16 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_r16 (gfc_array_i4 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_4_r4.c =================================================================== --- generated/minloc1_4_r4.c (Revision 250720) +++ generated/minloc1_4_r4.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_4_r4 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_4_r4 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_r4 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_r4 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_4_r8.c =================================================================== --- generated/minloc1_4_r8.c (Revision 250720) +++ generated/minloc1_4_r8.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_4_r8 (gfc_array_i4 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_4_r8 (gfc_array_i4 * const restrict retar GFC_INTEGER_4 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_4_r8 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_4_r8 (gfc_array_i4 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_8_i1.c =================================================================== --- generated/minloc1_8_i1.c (Revision 250720) +++ generated/minloc1_8_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_8_i1 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_8_i1 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_i1 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_i1 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_8_i16.c =================================================================== --- generated/minloc1_8_i16.c (Revision 250720) +++ generated/minloc1_8_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_8_i16 (gfc_array_i8 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_8_i16 (gfc_array_i8 * const restrict reta GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_i16 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_i16 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_8_i2.c =================================================================== --- generated/minloc1_8_i2.c (Revision 250720) +++ generated/minloc1_8_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_8_i2 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_8_i2 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_i2 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_i2 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_8_i4.c =================================================================== --- generated/minloc1_8_i4.c (Revision 250720) +++ generated/minloc1_8_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_8_i4 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_8_i4 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_i4 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_i4 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_8_i8.c =================================================================== --- generated/minloc1_8_i8.c (Revision 250720) +++ generated/minloc1_8_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_8_i8 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_8_i8 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_i8 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_i8 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_8_r10.c =================================================================== --- generated/minloc1_8_r10.c (Revision 250720) +++ generated/minloc1_8_r10.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_8_r10 (gfc_array_i8 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_8_r10 (gfc_array_i8 * const restrict reta GFC_INTEGER_8 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_r10 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_r10 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_8_r16.c =================================================================== --- generated/minloc1_8_r16.c (Revision 250720) +++ generated/minloc1_8_r16.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_8_r16 (gfc_array_i8 * const restrict retar int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_8_r16 (gfc_array_i8 * const restrict reta GFC_INTEGER_8 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_r16 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_r16 (gfc_array_i8 * const restrict reta dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_8_r4.c =================================================================== --- generated/minloc1_8_r4.c (Revision 250720) +++ generated/minloc1_8_r4.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_8_r4 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_8_r4 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_r4 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_r4 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minloc1_8_r8.c =================================================================== --- generated/minloc1_8_r8.c (Revision 250720) +++ generated/minloc1_8_r8.c (Arbeitskopie) @@ -52,9 +52,16 @@ minloc1_8_r8 (gfc_array_i8 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -224,8 +231,8 @@ mminloc1_8_r8 (gfc_array_i8 * const restrict retar GFC_INTEGER_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -235,6 +242,14 @@ mminloc1_8_r8 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -445,6 +460,13 @@ sminloc1_8_r8 (gfc_array_i8 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINLOC intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minval_i1.c =================================================================== --- generated/minval_i1.c (Revision 250720) +++ generated/minval_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ minval_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mminval_i1 (gfc_array_i1 * const restrict retarray GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_i1 (gfc_array_i1 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_i1 (gfc_array_i1 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minval_i16.c =================================================================== --- generated/minval_i16.c (Revision 250720) +++ generated/minval_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ minval_i16 (gfc_array_i16 * const restrict retarra int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mminval_i16 (gfc_array_i16 * const restrict retarr GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_i16 (gfc_array_i16 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_i16 (gfc_array_i16 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minval_i2.c =================================================================== --- generated/minval_i2.c (Revision 250720) +++ generated/minval_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ minval_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mminval_i2 (gfc_array_i2 * const restrict retarray GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_i2 (gfc_array_i2 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_i2 (gfc_array_i2 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minval_i4.c =================================================================== --- generated/minval_i4.c (Revision 250720) +++ generated/minval_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ minval_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mminval_i4 (gfc_array_i4 * const restrict retarray GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_i4 (gfc_array_i4 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_i4 (gfc_array_i4 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minval_i8.c =================================================================== --- generated/minval_i8.c (Revision 250720) +++ generated/minval_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ minval_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mminval_i8 (gfc_array_i8 * const restrict retarray GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_i8 (gfc_array_i8 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_i8 (gfc_array_i8 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minval_r10.c =================================================================== --- generated/minval_r10.c (Revision 250720) +++ generated/minval_r10.c (Arbeitskopie) @@ -52,9 +52,16 @@ minval_r10 (gfc_array_r10 * const restrict retarra int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mminval_r10 (gfc_array_r10 * const restrict retarr GFC_REAL_10 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_r10 (gfc_array_r10 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_r10 (gfc_array_r10 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minval_r16.c =================================================================== --- generated/minval_r16.c (Revision 250720) +++ generated/minval_r16.c (Arbeitskopie) @@ -52,9 +52,16 @@ minval_r16 (gfc_array_r16 * const restrict retarra int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mminval_r16 (gfc_array_r16 * const restrict retarr GFC_REAL_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_r16 (gfc_array_r16 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_r16 (gfc_array_r16 * const restrict retarr dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minval_r4.c =================================================================== --- generated/minval_r4.c (Revision 250720) +++ generated/minval_r4.c (Arbeitskopie) @@ -52,9 +52,16 @@ minval_r4 (gfc_array_r4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mminval_r4 (gfc_array_r4 * const restrict retarray GFC_REAL_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_r4 (gfc_array_r4 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_r4 (gfc_array_r4 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/minval_r8.c =================================================================== --- generated/minval_r8.c (Revision 250720) +++ generated/minval_r8.c (Arbeitskopie) @@ -52,9 +52,16 @@ minval_r8 (gfc_array_r8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -217,8 +224,8 @@ mminval_r8 (gfc_array_r8 * const restrict retarray GFC_REAL_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -228,6 +235,14 @@ mminval_r8 (gfc_array_r8 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -433,6 +448,13 @@ sminval_r8 (gfc_array_r8 * const restrict retarray dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in MINVAL intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/norm2_r10.c =================================================================== --- generated/norm2_r10.c (Revision 250720) +++ generated/norm2_r10.c (Arbeitskopie) @@ -55,9 +55,16 @@ norm2_r10 (gfc_array_r10 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in NORM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; Index: generated/norm2_r16.c =================================================================== --- generated/norm2_r16.c (Revision 250720) +++ generated/norm2_r16.c (Arbeitskopie) @@ -59,9 +59,16 @@ norm2_r16 (gfc_array_r16 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in NORM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; Index: generated/norm2_r4.c =================================================================== --- generated/norm2_r4.c (Revision 250720) +++ generated/norm2_r4.c (Arbeitskopie) @@ -55,9 +55,16 @@ norm2_r4 (gfc_array_r4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in NORM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; Index: generated/norm2_r8.c =================================================================== --- generated/norm2_r8.c (Revision 250720) +++ generated/norm2_r8.c (Arbeitskopie) @@ -55,9 +55,16 @@ norm2_r8 (gfc_array_r8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in NORM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; Index: generated/parity_l1.c =================================================================== --- generated/parity_l1.c (Revision 250720) +++ generated/parity_l1.c (Arbeitskopie) @@ -52,9 +52,16 @@ parity_l1 (gfc_array_l1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; Index: generated/parity_l16.c =================================================================== --- generated/parity_l16.c (Revision 250720) +++ generated/parity_l16.c (Arbeitskopie) @@ -52,9 +52,16 @@ parity_l16 (gfc_array_l16 * const restrict retarra int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; Index: generated/parity_l2.c =================================================================== --- generated/parity_l2.c (Revision 250720) +++ generated/parity_l2.c (Arbeitskopie) @@ -52,9 +52,16 @@ parity_l2 (gfc_array_l2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; Index: generated/parity_l4.c =================================================================== --- generated/parity_l4.c (Revision 250720) +++ generated/parity_l4.c (Arbeitskopie) @@ -52,9 +52,16 @@ parity_l4 (gfc_array_l4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; Index: generated/parity_l8.c =================================================================== --- generated/parity_l8.c (Revision 250720) +++ generated/parity_l8.c (Arbeitskopie) @@ -52,9 +52,16 @@ parity_l8 (gfc_array_l8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PARITY intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; Index: generated/product_c10.c =================================================================== --- generated/product_c10.c (Revision 250720) +++ generated/product_c10.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_c10 (gfc_array_c10 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_c10 (gfc_array_c10 * const restrict retar GFC_COMPLEX_10 * restrict dest; const GFC_COMPLEX_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_c10 (gfc_array_c10 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_c10 (gfc_array_c10 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_c16.c =================================================================== --- generated/product_c16.c (Revision 250720) +++ generated/product_c16.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_c16 (gfc_array_c16 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_c16 (gfc_array_c16 * const restrict retar GFC_COMPLEX_16 * restrict dest; const GFC_COMPLEX_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_c16 (gfc_array_c16 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_c16 (gfc_array_c16 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_c4.c =================================================================== --- generated/product_c4.c (Revision 250720) +++ generated/product_c4.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_c4 (gfc_array_c4 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_c4 (gfc_array_c4 * const restrict retarra GFC_COMPLEX_4 * restrict dest; const GFC_COMPLEX_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_c4 (gfc_array_c4 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_c4 (gfc_array_c4 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_c8.c =================================================================== --- generated/product_c8.c (Revision 250720) +++ generated/product_c8.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_c8 (gfc_array_c8 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_c8 (gfc_array_c8 * const restrict retarra GFC_COMPLEX_8 * restrict dest; const GFC_COMPLEX_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_c8 (gfc_array_c8 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_c8 (gfc_array_c8 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_i1.c =================================================================== --- generated/product_i1.c (Revision 250720) +++ generated/product_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_i1 (gfc_array_i1 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_i1 (gfc_array_i1 * const restrict retarra GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_i1 (gfc_array_i1 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_i1 (gfc_array_i1 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_i16.c =================================================================== --- generated/product_i16.c (Revision 250720) +++ generated/product_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_i16 (gfc_array_i16 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_i16 (gfc_array_i16 * const restrict retar GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_i16 (gfc_array_i16 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_i16 (gfc_array_i16 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_i2.c =================================================================== --- generated/product_i2.c (Revision 250720) +++ generated/product_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_i2 (gfc_array_i2 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_i2 (gfc_array_i2 * const restrict retarra GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_i2 (gfc_array_i2 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_i2 (gfc_array_i2 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_i4.c =================================================================== --- generated/product_i4.c (Revision 250720) +++ generated/product_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_i4 (gfc_array_i4 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_i4 (gfc_array_i4 * const restrict retarra GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_i4 (gfc_array_i4 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_i4 (gfc_array_i4 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_i8.c =================================================================== --- generated/product_i8.c (Revision 250720) +++ generated/product_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_i8 (gfc_array_i8 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_i8 (gfc_array_i8 * const restrict retarra GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_i8 (gfc_array_i8 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_i8 (gfc_array_i8 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_r10.c =================================================================== --- generated/product_r10.c (Revision 250720) +++ generated/product_r10.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_r10 (gfc_array_r10 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_r10 (gfc_array_r10 * const restrict retar GFC_REAL_10 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_r10 (gfc_array_r10 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_r10 (gfc_array_r10 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_r16.c =================================================================== --- generated/product_r16.c (Revision 250720) +++ generated/product_r16.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_r16 (gfc_array_r16 * const restrict retarr int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_r16 (gfc_array_r16 * const restrict retar GFC_REAL_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_r16 (gfc_array_r16 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_r16 (gfc_array_r16 * const restrict retar dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_r4.c =================================================================== --- generated/product_r4.c (Revision 250720) +++ generated/product_r4.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_r4 (gfc_array_r4 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_r4 (gfc_array_r4 * const restrict retarra GFC_REAL_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_r4 (gfc_array_r4 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_r4 (gfc_array_r4 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/product_r8.c =================================================================== --- generated/product_r8.c (Revision 250720) +++ generated/product_r8.c (Arbeitskopie) @@ -52,9 +52,16 @@ product_r8 (gfc_array_r8 * const restrict retarray int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ mproduct_r8 (gfc_array_r8 * const restrict retarra GFC_REAL_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ mproduct_r8 (gfc_array_r8 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ sproduct_r8 (gfc_array_r8 * const restrict retarra dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in PRODUCT intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_c10.c =================================================================== --- generated/sum_c10.c (Revision 250720) +++ generated/sum_c10.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_c10 (gfc_array_c10 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_c10 (gfc_array_c10 * const restrict retarray, GFC_COMPLEX_10 * restrict dest; const GFC_COMPLEX_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_c10 (gfc_array_c10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_c10 (gfc_array_c10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_c16.c =================================================================== --- generated/sum_c16.c (Revision 250720) +++ generated/sum_c16.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_c16 (gfc_array_c16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_c16 (gfc_array_c16 * const restrict retarray, GFC_COMPLEX_16 * restrict dest; const GFC_COMPLEX_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_c16 (gfc_array_c16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_c16 (gfc_array_c16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_c4.c =================================================================== --- generated/sum_c4.c (Revision 250720) +++ generated/sum_c4.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_c4 (gfc_array_c4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_c4 (gfc_array_c4 * const restrict retarray, GFC_COMPLEX_4 * restrict dest; const GFC_COMPLEX_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_c4 (gfc_array_c4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_c4 (gfc_array_c4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_c8.c =================================================================== --- generated/sum_c8.c (Revision 250720) +++ generated/sum_c8.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_c8 (gfc_array_c8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_c8 (gfc_array_c8 * const restrict retarray, GFC_COMPLEX_8 * restrict dest; const GFC_COMPLEX_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_c8 (gfc_array_c8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_c8 (gfc_array_c8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_i1.c =================================================================== --- generated/sum_i1.c (Revision 250720) +++ generated/sum_i1.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_i1 (gfc_array_i1 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_i1 (gfc_array_i1 * const restrict retarray, GFC_INTEGER_1 * restrict dest; const GFC_INTEGER_1 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_i1 (gfc_array_i1 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_i16.c =================================================================== --- generated/sum_i16.c (Revision 250720) +++ generated/sum_i16.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_i16 (gfc_array_i16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_i16 (gfc_array_i16 * const restrict retarray, GFC_INTEGER_16 * restrict dest; const GFC_INTEGER_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_i16 (gfc_array_i16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_i2.c =================================================================== --- generated/sum_i2.c (Revision 250720) +++ generated/sum_i2.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_i2 (gfc_array_i2 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_i2 (gfc_array_i2 * const restrict retarray, GFC_INTEGER_2 * restrict dest; const GFC_INTEGER_2 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_i2 (gfc_array_i2 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_i4.c =================================================================== --- generated/sum_i4.c (Revision 250720) +++ generated/sum_i4.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_i4 (gfc_array_i4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_i4 (gfc_array_i4 * const restrict retarray, GFC_INTEGER_4 * restrict dest; const GFC_INTEGER_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_i4 (gfc_array_i4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_i8.c =================================================================== --- generated/sum_i8.c (Revision 250720) +++ generated/sum_i8.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_i8 (gfc_array_i8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_i8 (gfc_array_i8 * const restrict retarray, GFC_INTEGER_8 * restrict dest; const GFC_INTEGER_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_i8 (gfc_array_i8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_r10.c =================================================================== --- generated/sum_r10.c (Revision 250720) +++ generated/sum_r10.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_r10 (gfc_array_r10 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_r10 (gfc_array_r10 * const restrict retarray, GFC_REAL_10 * restrict dest; const GFC_REAL_10 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_r10 (gfc_array_r10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_r10 (gfc_array_r10 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_r16.c =================================================================== --- generated/sum_r16.c (Revision 250720) +++ generated/sum_r16.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_r16 (gfc_array_r16 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_r16 (gfc_array_r16 * const restrict retarray, GFC_REAL_16 * restrict dest; const GFC_REAL_16 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_r16 (gfc_array_r16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_r16 (gfc_array_r16 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_r4.c =================================================================== --- generated/sum_r4.c (Revision 250720) +++ generated/sum_r4.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_r4 (gfc_array_r4 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_r4 (gfc_array_r4 * const restrict retarray, GFC_REAL_4 * restrict dest; const GFC_REAL_4 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_r4 (gfc_array_r4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_r4 (gfc_array_r4 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n); Index: generated/sum_r8.c =================================================================== --- generated/sum_r8.c (Revision 250720) +++ generated/sum_r8.c (Arbeitskopie) @@ -52,9 +52,16 @@ sum_r8 (gfc_array_r8 * const restrict retarray, int continue_loop; /* Make dim zero based to avoid confusion. */ + rank = GFC_DESCRIPTOR_RANK (array) - 1; dim = (*pdim) - 1; - rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len < 0) len = 0; @@ -203,8 +210,8 @@ msum_r8 (gfc_array_r8 * const restrict retarray, GFC_REAL_8 * restrict dest; const GFC_REAL_8 * restrict base; const GFC_LOGICAL_1 * restrict mbase; - int rank; - int dim; + index_type rank; + index_type dim; index_type n; index_type len; index_type delta; @@ -214,6 +221,14 @@ msum_r8 (gfc_array_r8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + len = GFC_DESCRIPTOR_EXTENT(array,dim); if (len <= 0) return; @@ -391,6 +406,13 @@ ssum_r8 (gfc_array_r8 * const restrict retarray, dim = (*pdim) - 1; rank = GFC_DESCRIPTOR_RANK (array) - 1; + if (unlikely (dim < 0 || dim > rank)) + { + runtime_error ("Dim argument incorrect in SUM intrinsic: " + "is %ld, should be between 1 and %ld", + (long int) dim + 1, (long int) rank + 1); + } + for (n = 0; n < dim; n++) { extent[n] = GFC_DESCRIPTOR_EXTENT(array,n);