Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
18 Views

iford 19.0 bug recursive derived type move_alloc

Hi,

I get an error, when running the following program compiled with iford 19.0 without any compiler options on linux.

! ifort (IFORT) 19.0.1.144 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

 

0 Kudos
6 Replies
Highlighted
Beginner
18 Views

sorry, the error is: forrtl: severe (153): allocatable array or pointer is not allocated

0 Kudos
Highlighted
Honored Contributor I
18 Views

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..

0 Kudos
Highlighted
Valued Contributor I
18 Views

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:

https://software.intel.com/en-us/comment/1929514

Intel Support notified me on Jan 17 that apparently that bug is fixed in the upcoming 19.0.2, so let's see.

0 Kudos
Highlighted
Beginner
18 Views

I tested the program with ifort version 19.0.2.187, 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.

0 Kudos
Highlighted
Valued Contributor I
18 Views

Yes, you should report this regression.

 

0 Kudos
Highlighted
Moderator
18 Views

An update 3 is coming very shortly and is expected to have the anticipated bugfixes.

0 Kudos