That is a good question, and I do not know the answer. I expect these concerns are valid. I have done these deallocations both ways. The statement deallocate(list) will be implemented by deallocating the list starting from the head (first value) and then traversing to the tail (last value). That requires a call stack to maintain the addresses of all the nodes. When a programmer writes a loop to manually deallocate the nodes, it would be done in the other order, last-to-first, and no call stack is required. From the previous posted code, the manual list deallocation could be done as:
do i = n, 1, -1 ! deallocate one member at a time.
call move_alloc( from=list%prev, to=new )
call move_alloc( from=new, to=list )
enddo
This reuses the new variable rather than storing the whole address stack. There are no deallocate() statements required because they are implicit within the move_alloc() calls.