3 ! Tests the fix for PR67177 in which MOVE_ALLOC was not assigning the string
4 ! length for deferred length characters.
6 ! Contributed by <templed@tcd.ie>
12 character(:), Allocatable
:: text
16 type(string
), allocatable
, dimension(:) :: strlist
19 type(strings
) :: teststrs
20 type(string
) :: tmpstr
21 integer :: strlen
= 20
23 allocate (teststrs
%strlist(1))
24 allocate (character(len
=strlen
) :: tmpstr
%text
)
26 allocate (character(len
=strlen
) :: teststrs
%strlist(1)%text
)
28 ! Full string reference was required because reallocation on assignment is
29 ! functioning when it should not if the lhs is a substring - PR67977
30 tmpstr
%text(1:3) = 'foo'
32 if (.not
.allocated (teststrs
%strlist(1)%text
)) call abort
33 if (len (tmpstr
%text
) .ne
. strlen
) call abort
35 call move_alloc(tmpstr
%text
,teststrs
%strlist(1)%text
)
37 if (.not
.allocated (teststrs
%strlist(1)%text
)) call abort
38 if (len (teststrs
%strlist(1)%text
) .ne
. strlen
) call abort
39 if (trim (teststrs
%strlist(1)%text(1:3)) .ne
. 'foo') call abort
41 ! Clean up so that valgrind reports all allocated memory freed.
42 if (allocated (teststrs
%strlist(1)%text
)) deallocate (teststrs
%strlist(1)%text
)
43 if (allocated (teststrs
%strlist
)) deallocate (teststrs
%strlist
)