Hi Jerry,

See attached patch. Resolution drops a substring of an array section
only when its range is a constant covering the whole string. For
c(:)(1:n), dc(:)(:len(dc)) or a substring of an assumed-length dummy,
the reference stays, gfc_is_not_contiguous treats any reference after
the section as proof, and so IS_CONTIGUOUS folds to .false. and a
CONTIGUOUS pointer assignment is rejected. The run-time path cannot
answer either, because gfc_conv_expr_descriptor builds a temporary for
a substring section. With the patch, a trailing substring is proof
only when substring_is_partial shows it starts after 1 or ends before
the length; otherwise IS_CONTIGUOUS tests the array without the
substring at run time and ANDs that with start == 1 and end == the
string length.

gfc_is_not_contiguous also decides copy-in for a CONTIGUOUS, TARGET
dummy in trans-expr.cc; passing c(:)(1:n) to one still creates a
temporary and copies back correctly.

Regression tested on x86_64.
I think this (and possibly other) cases would conclude that
something with a substring is simply contiguous, which is
excluded by F2023, 9.5.4, subclause 2.  Shouldn't this be
conditional on !strict?

(I believe my own recent patch has the same problem, BTW).

Best regards

        Thomas

Reply via email to