I get an error, when running the following program compiled with iford 19.0 without any compiler options on linux.
! ifort (IFORT) 220.127.116.11 20181018 program ifort_bug_recursive_type_move_alloc implicit none type stack_t type(stack_t), allocatable :: next end type stack_t type(stack_t), allocatable :: stack, tmp call push(stack) ! in the main program the code works fine call move_alloc(from=stack%next, to=tmp) call move_alloc(from=tmp, to=stack) call push(stack) ! when executed in a subroutine it fails call pop(stack) contains subroutine pop(stack) type(stack_t), intent(in out), allocatable :: stack type(stack_t), allocatable :: tmp !! this pop variant working fine ! call move_alloc(from=stack, to=tmp) ! call move_alloc(from=tmp%next, to=stack) call move_alloc(from=stack%next, to=tmp) ! forrtl: severe (153): allocatable array or pointer is not allocated ! deallocate(stack) ! fixes the bug! call move_alloc(from=tmp, to=stack) end subroutine pop subroutine push(stack) type(stack_t), intent(in out), allocatable :: stack type(stack_t), allocatable :: tmp call move_alloc(from=stack, to=tmp) stack = stack_t() call move_alloc(from=tmp, to=stack%next) end subroutine push end program ifort_bug_recursive_type_move_alloc
This looks like a bug in Intel Fortran compiler, you should submit a support request at the Intel Online Service Center: https://supporttickets.intel.com/?lang=en-US
The Fortran standard clearly states TO is an INTENT(OUT) dummy argument in MOVE_ALLOC intrinsic subroutine, so you should not have to add the deallocate(stack) instruction prior to invoking this procedure..
This looks very similar to a regression in 19.0.0beta from the earliest point one, which was reported right away, but made it into an update of the beta, the 19.0.0 release, and the first update, 19.0.1, which I commented upon here:
Intel Support notified me on Jan 17 that apparently that bug is fixed in the upcoming 19.0.2, so let's see.
I tested the program with ifort version 18.104.22.168, the bug is not fixed yet and gives the same error as before.
Do I have to submit a support request if I only want to report the bug, or is this forum thread sufficient.