https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85547
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
--- Comment #6 from anlauf at gcc dot gnu.org ---
The trim() and string concatenation are not even needed to see the string
length getting lost.
Example:
program p
implicit none
character(10) :: path = 'xyz/'
print *, len ( [ character(16) :: path ] ) ! ok
call print_string ( [ character(16) :: path ] ) ! typespec lost
contains
subroutine print_string (s)
character(*), intent(in) :: s(:)
print *, len(s), len(s)==16
end subroutine
end program
prints:
16
10 F
Inspection of the tree-dump shows that the temporary creation for the
subroutine call looks like we initially have the proper string length
after the array constructor
atmp.6.dtype = {.elem_len=16, .rank=1, .type=6};
atmp.6.dim[0].stride = 1;
atmp.6.dim[0].lbound = 0;
atmp.6.dim[0].ubound = 0;
atmp.6.span = 16;
which gets copied to the temporary
atmp.9.dtype = {.elem_len=10, .rank=1, .type=6};
atmp.9.dim[0].stride = 1;
atmp.9.dim[0].lbound = 0;
atmp.9.dim[0].ubound = 0;
atmp.9.span = 10;
I wonder where we get this from.
Besides, we actually create two temporaries in succession instead of just
one...