From: Jakub Jelinek <jakub@redhat.com>
To: Tobias Burnus <burnus@net-b.de>
Cc: fortran@gcc.gnu.org
Subject: Re: [Patch, Fortran] PR fortran/83522 – reject array-valued substrings
Date: Thu, 11 Oct 2018 10:46:00 -0000 [thread overview]
Message-ID: <20181011104640.GA25103@tucnak> (raw)
In-Reply-To: <c0ed507e-bf17-ea71-6715-906c10ee054d@net-b.de>
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
next prev parent reply other threads:[~2018-10-11 10:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-08 19:45 Tobias Burnus
2018-10-08 22:15 ` Thomas Koenig
2018-10-10 23:12 ` Paul Richard Thomas
2018-10-11 13:56 ` David Edelsohn
2018-10-11 14:20 ` David Edelsohn
2018-10-11 14:39 ` Paul Richard Thomas
2018-10-11 10:46 ` Jakub Jelinek [this message]
2018-10-11 19:37 ` Tobias Burnus
2018-10-11 19:40 ` Paul Richard Thomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181011104640.GA25103@tucnak \
--to=jakub@redhat.com \
--cc=burnus@net-b.de \
--cc=fortran@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).