Is the run-time behavior shown below with the following code correct?
program p implicit none type :: t character(len=:), allocatable :: s end type t type(t), allocatable :: foo type(t), allocatable :: bar type(t), allocatable :: tmp foo = t( "foo" ) bar = t( "bar" ) asc: associate ( s1 => foo, s2 => bar ) print *, "before swap: " print *, " foo = ", s1%s print *, " bar = ", s2%s !.. swap foo and bar call move_alloc(bar, tmp) call move_alloc(foo, bar) call move_alloc(tmp, foo) print *, "after swap: " print *, " foo = ", s1%s print *, " bar = ", s2%s end associate asc print *, "after associate: " print *, " foo = ", foo%s print *, " bar = ", bar%s stop end program p
Upon execution, the response is:
before swap: foo = foo bar = bar after swap: foo = foo bar = bar after associate: foo = bar bar = foo