Skip to content

Commit 7211ce8

Browse files
authored
Fix aliased string move interface (#773)
2 parents 8476d65 + 9703a80 commit 7211ce8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: src/stdlib_string_type.fypp

+6-5
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,13 @@ contains
679679
!> Moves the allocated character scalar from 'from' to 'to'
680680
!> No output
681681
elemental subroutine move_string_string(from, to)
682-
type(string_type), intent(inout) :: from
683-
type(string_type), intent(inout) :: to
684-
character(:), allocatable :: tmp
682+
type(string_type), intent(inout), target :: from
683+
type(string_type), intent(inout), target :: to
684+
type(string_type), pointer :: fromp
685685

686-
call move_alloc(from%raw, tmp)
687-
call move_alloc(tmp, to%raw)
686+
fromp => from
687+
if (associated(fromp,to)) return
688+
call move_alloc(from%raw, to%raw)
688689

689690
end subroutine move_string_string
690691

0 commit comments

Comments
 (0)