From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15672 invoked by alias); 11 Oct 2018 10:46:55 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 15575 invoked by uid 89); 11 Oct 2018 10:46:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=4.6 required=5.0 tests=BAYES_00,GARBLED_SUBJECT,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=HTo:U*burnus, f2018, Jerry, H*f:sk:c0ed507 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Oct 2018 10:46:46 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2584530820C1; Thu, 11 Oct 2018 10:46:45 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-222.ams2.redhat.com [10.36.117.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B5EBC827BE; Thu, 11 Oct 2018 10:46:44 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w9BAkgjr025116; Thu, 11 Oct 2018 12:46:42 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w9BAkedw025115; Thu, 11 Oct 2018 12:46:40 +0200 Date: Thu, 11 Oct 2018 10:46:00 -0000 From: Jakub Jelinek To: Tobias Burnus Cc: fortran@gcc.gnu.org Subject: Re: [Patch, Fortran] PR =?utf-8?Q?fortran?= =?utf-8?B?LzgzNTIyIOKAkw==?= reject array-valued substrings Message-ID: <20181011104640.GA25103@tucnak> Reply-To: Jakub Jelinek References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-SW-Source: 2018-10/txt/msg00044.txt.bz2 On Mon, Oct 08, 2018 at 09:44:57PM +0200, Tobias Burnus wrote: > as the PR (and the attached testcase) shows, gfortran doesn't handle > noncontiguous access with substrings. Namely, "str_array(:)(1:5)" is > mishandled (segfault while building the "tree" as expr == NULL). > > As Jerry has dug up in the standard (F2008, R610 alias F2018, R908), > substrings are only permitted on scalars (or array elements). – [gfortran > has some partial support for noncontiguous memory as actual argument the now > rejected test cases show.] > > In words of the standard (here: F2018): > > 9.4.1  Substrings > > A substring is a contiguous portion of a character string (7.4.4). > > R908   substring   is   parent-string  ( substring-range ) > > R909   parent-string >             is   scalar-variable-name >             or  array-element >             or  coindexed-named-object >             or  scalar-structure-component >             or  scalar-constant > > The patch adds a check to the variable resolving – it comes too late to > print a nice error message for "string(:)(:)"; that statement gets matched > unsuccessfully and at the end the buffered error message of match_variable > (unexpected character "(") gets printed. – One could reject it earlier but > the code doesn't seem to be that nice. (See PR for a variant.) > > Build and regtested on x86_64-linux. > OK for the trunk? As I wrote in the PR, I believe it is incorrect and should be reverted. While for character(kind=1,length=4) :: f(4,5) e.g. f(:,:)(1:2) is not matching the substring non-terminal, it is IMNSHO matching the array-section non-terminal: R918 array-section             is data-ref [ ( substring-range ) ]             or complex-part-designator C925 (R918) Exactly one part-ref shall have nonzero rank, and either the final part-ref shall have a section-subscript-list with nonzero rank, another part-ref shall have nonzero rank, or the complex-part-designator shall be an array. C926 (R918) If a substring-range appears, the rightmost part-name shall be of type character. and in that case: An array element is a scalar. An array section is an array. If a substring-range appears in an array-section, each element is the designated substring of the corresponding element of the array section. applies. Jakub