Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

Error when passing a null pointer to an optional argument with the "-check all" option

$
0
0

Hi,

An run-time error is given by ifort version 15.0.0 using the "-check all" option when passing a null pointer to an optional argument.

Without the the "-check all" option, the result seems correct.

Gfortran is ok

! This code passes a null pointer to an optional argument of a procedure.
! Athough the code seems to works fine, it leads to the following error when compiled with "-check all":
! forrtl: severe (408): fort: (7): Attempt to use pointer PTR when it is not associated with a target
! Gfortran compiles and run fine.
! Tested with ifort version 15.0.0
Program Main
  implicit none
  integer ,target :: i = 0
  integer ,pointer :: Ptr
  write(*,*) "Calling with arg"
  call Proc( i )
  write(*,*) "Calling without arg"
  call Proc()
  Ptr => i
  write(*,*) "Calling with Ptr => i"
  call Proc(Ptr)
  Ptr => null()         ! This should be ok but but causes an error when compiled using the "-check all" option
  write(*,*) "Calling with Ptr => null"
  call Proc(Ptr)
  contains
Subroutine Proc( Arg )
  integer       ,optional       ,intent(inout)     ::      Arg
  if (Present(Arg) ) then
    write(*,*) "  Present argument"
    Arg = Arg + 1
  else
    write(*,*) "  Absent argument"
  end if
End Subroutine
End Program

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



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