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

non-allocated array for optional argument with cheks turned on

$
0
0

Dear all,

I think, the ifort compiler 16.0.0 and also previous ones behave strange, when turning on pointer checking ("-check pointers") and passing an unallocated array as actual argument to an optional array dummy argument in a subroutine. The code below compiles and runs fine without the "-check pointers" option, but triggers a false error during run-time when the option is turned on during the compilation.

Bálint

module testmod
  implicit none

contains

  subroutine testSub(aa, bb)
    integer, intent(in) :: aa(:)
    integer, intent(in), optional :: bb(:)

    print *, "AA:", aa
    if (present(bb)) then
      print *, "BB:", bb
    else
      print *, "BB NOT PRESENT"
    end if

  end subroutine testSub

end module testmod


program test
  use testmod
  implicit none

  integer, allocatable :: aa(:), bb(:)

  allocate(aa(2))
  aa(:) = -1
  call testSub(aa, bb=bb)
  allocate(bb(2))
  aa(:) = -2
  bb(:) = -4
  call testSub(aa, bb=bb)

end program test

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



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