Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28757 Discussions

iford 19.0 bug recursive derived type move_alloc

Elias_L_
Beginner
669 Views

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
Elias_L_
Beginner
669 Views

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

0 Kudos
FortranFan
Honored Contributor III
669 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
Juergen_R_R
Valued Contributor II
669 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
Elias_L_
Beginner
669 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
Juergen_R_R
Valued Contributor II
669 Views

Yes, you should report this regression.

 

0 Kudos
Devorah_H_Intel
Moderator
669 Views

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

0 Kudos
Reply