Tobias Burnus
2018-10-08 19:44:57 UTC
Hi all,
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?
Cheers
Tobias
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?
Cheers
Tobias