Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

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

FlyingHermes
New Contributor I
1,214 Views

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

 

0 Kudos
2 Replies
Steven_L_Intel1
Employee
1,214 Views

Thanks - escalated as issue DPD200369832.

0 Kudos
Steven_L_Intel1
Employee
1,214 Views

I expect this to be fixed in the 16.0 release.

0 Kudos
Reply