Skip to content

Commit ae4a38f

Browse files
committed
Fix bug related to string_type move fortran-lang#731 fortran-lang#735
1 parent 05941b0 commit ae4a38f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: src/stdlib_string_type.fypp

+11-2
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,18 @@ contains
680680
!> No output
681681
elemental subroutine move_string_string(from, to)
682682
type(string_type), intent(inout) :: from
683-
type(string_type), intent(out) :: to
683+
type(string_type), intent(inout) :: to
684+
685+
if(.not.allocated(from%raw))then
686+
if(allocated(to%raw))deallocate(to%raw)
687+
return
688+
endif
684689

685-
call move_alloc(from%raw, to%raw)
690+
if(from%raw .eq. to%raw)then
691+
deallocate(from%raw)
692+
else
693+
call move_alloc(from%raw, to%raw)
694+
endif
686695

687696
end subroutine move_string_string
688697

0 commit comments

Comments
 (0)