Skip to content

Commit

Permalink
Fix bug related to string_type move #731 #735
Browse files Browse the repository at this point in the history
  • Loading branch information
jvdp1 committed Sep 3, 2023
1 parent 05941b0 commit ae4a38f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/stdlib_string_type.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,18 @@ contains
!> No output
elemental subroutine move_string_string(from, to)
type(string_type), intent(inout) :: from
type(string_type), intent(out) :: to
type(string_type), intent(inout) :: to

if(.not.allocated(from%raw))then
if(allocated(to%raw))deallocate(to%raw)
return
endif

call move_alloc(from%raw, to%raw)
if(from%raw .eq. to%raw)then
deallocate(from%raw)
else
call move_alloc(from%raw, to%raw)
endif

end subroutine move_string_string

Expand Down

0 comments on commit ae4a38f

Please sign in to comment.