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

Segfault when passing non-allocated class variable to optional dummy arg

$
0
0

The binary produced with the ifort 17.0.4 @ x86_64/Linux crashes, if a non-allocated class variable is passed to an optional dummy argument. The code below demonstrates the issue.

Best regards,

Bálint

module mymod
  implicit none

  type :: BaseType
    integer :: ii = 0
  end type BaseType

contains

  subroutine optional(bt)
    class(BaseType), optional :: bt

    print *, 'PRESENT:', present(bt)
    if (present(bt)) then
      bt%ii = 42
    end if

  end subroutine optional

end module mymod


program myprog
  use mymod
  implicit none

  class(BaseType), allocatable :: btClass
  type(BaseType), allocatable ::  btType

  allocate(btType)
  call move_alloc(btType, btClass)
  call optional(btClass)
  deallocate(btClass)
  ! Crashes here
  call optional(btClass)

end program myprog

 


Viewing all articles
Browse latest Browse all 2746

Latest Images

Trending Articles



Latest Images

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