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

Finalization: segfault on optional intent(out) allocatable

Ferdinand_T_
New Contributor II
253 Views
The finalization of a non-present optional intent(out) allocatable dummy argument produces a segmentation fault at runtime when the following code is compiled with ifort 16.0.3. This is the same issue as reported some years ago in https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/494928 (topic closed) and faintly ressembles https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/327918 (pointer instead of allocatabe).
module m
    ! finalized t
    type :: t
    contains
        final :: tfinal
    end type
contains
    subroutine tfinal(a)
        type(t), intent(inout) :: a
    end subroutine

    ! pass optional t, finalized on entry
    subroutine pass(a)
        type(t), allocatable, intent(out), optional :: a
        print *, 'passed'
    end subroutine
end module

program p
    use m
    type(t), allocatable :: a

    call pass(a)        ! ok
    call pass()         ! segfault
end program
It would certainly be nice to have a fix for this, or some ideas for workarounds without having to change the dummy's attributes. Kind regards Ferdinand PS: Syntax-highlighting as suggested using (left-angle bracket) pre class="brush:fortran" (right-angle bracket) doesn't work in my post.
0 Kudos
1 Reply
Xiaoping_D_Intel
Employee
253 Views

Thank you for reporting this problem. I have opened a bug report for it. The report ID is DPD200414190

 

Thanks,

Xiaoping Duan

Intel Customer Support

0 Kudos
Reply