Re: [Patch, Fortran] PR fortran/83522 – reject array-valued substrings
Paul Richard Thomas
paul.richard.thomas@gmail.com
Thu Oct 11 19:40:00 GMT 2018
Hi Tobias,
I am sorry that your return has proven to be a bit bloody. Thanks for
reverting it. I am afraid that Jerry missed the context completely.
Regards
Paul
On Thu, 11 Oct 2018 at 20:37, Tobias Burnus <burnus@net-b.de> wrote:
>
> In light of the somehow missed test-suite fails and the discussion about
> rejecting too much, I have reverted the patch with commit r83522.
>
> Tobias
>
> Am 11.10.18 um 12:46 schrieb Jakub Jelinek:
> > 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
--
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein
More information about the Fortran
mailing list