After fixing, 43072 and friends, one excess copy-in and copy-out remains, where a substring describes the declared string length. The testcase is in internal_pack_9.f90: subroutine foo2 implicit none external foo character(len=20) :: str(2) = '1234567890' call foo(str(:)(1:20)) ! This is still not fixed. end Paul
See also PR 31821.
We have to watch out for aliasing here; if foo changes the arguments, we have to have a copy. Compare PR 47065.
Hm, maybe one could simply remove the substring during resolution.
Created attachment 45431 [details] Patch which works, but causes some regressions Apparently, in argument_checking_13.f90, the test in the last routine interface subroutine rlv3(y) character :: y(3) end subroutine rlv3 end interface character(2) :: assumed_sh_dummy(:,:,:) ... call rlv3(assumed_sh_dummy(1,1,1)(1:2)) ! { dg-error "contains too few elements" } does not trigger the warning if it is replaced by call rlv3(assumed_sh_dummy(1,1,1)) So, this needs another test.
Author: tkoenig Date: Tue Jan 15 22:20:26 2019 New Revision: 267954 URL: https://gcc.gnu.org/viewcvs?rev=267954&root=gcc&view=rev Log: 2019-01-15 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/43136 * resolve.c (resolve_array_ref): Add equal_length argument; set it if the length of the substring equals that of the orignal variable. (resolve_ref): Remove the substring if it is equal in length to the original variable, unless it is an EXPR_SUBSTRING). 2019-01-15 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/43136 * gfortran.dg/actual_array_substr_3.f90: New test. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/testsuite/ChangeLog
Actually fixed in r267953, the original commit had the wrong PR number. Closing.