Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
13 Views

Optional argument confusion when using '-standard-semantics'

Dear all,

It seems to me that ifort 16.0.3 has some difficulties with optional argument passing, when using the -standard-semantics option. The code below demonstrates the issue. The present() query in the subroutine returns false, although the actual argument is an allocated pointer. Changing the dummy argument to be an assumed-shape array cures the problem, the same way as leaving away the -standard-semantics option does it as well.

Bálint

module bugtestmod
  implicit none

contains

  subroutine optarg(array)
    real, intent(in), optional :: array(3,3)

    print *, 'PRESENT?', present(array)

  end subroutine optarg

end module bugtestmod


program bugtest
  use bugtestmod
  implicit none

  real, pointer :: array(:,:)

  allocate(array(3,3))
  array(:,:) = 1.0
  call optarg(array)

end program bugtest

 

0 Kudos
5 Replies
Highlighted
13 Views

Very interesting. I can reproduce this and we'll investigate.

0 Kudos
Highlighted
13 Views

The specific option that triggers the problem is -fpscomp logicals, which is implied by -standard-semantics. It's not PRESENT that is the issue but rather the argument is being passed incorrectly, causing PRESENT to fail (and also the dummy argument to be unusable.) Why -fpscomp logicals should have such an effect, I have no idea, and I have asked the developers to figure it out. Issue ID is DPD200412406.

If you want a workaround, add -fpscomp nologicals.

0 Kudos
Highlighted
Beginner
13 Views

Indeed an interesting cross-effect. Dear Steve, thank you for your fast response and workaround suggestion.

Bálint

0 Kudos
Highlighted
13 Views

This problem has been fixed. I think the fix will be in the 17.0 product release.

0 Kudos
Highlighted
13 Views

The fix should also appear in 16.0.4.

0 Kudos