Quantcast
Channel: Intel® Software - Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2746

iford 19.0 bug recursive derived type move_alloc

$
0
0

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

 


Viewing all articles
Browse latest Browse all 2746

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>