Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28815 Discussions

Argument association with CLASS pointer dummy variables

Harald1
New Contributor II
492 Views

Hello,

the following code suggests that ifort/ifx do not implement the change between F2008 and F2018:

program main
  implicit none
  type t
    integer :: i
  end type t

  type(t),  allocatable, target :: xa
  type(t),  pointer             :: xp
  class(t), allocatable, target :: ya
  class(t), pointer             :: yp

  call foo_p (xp) ! Invalid & detected
  call foo_p (xa) ! Valid in F2018, but rejected

  call foo_p (yp) ! Valid, OK
  call foo_p (ya) ! Valid, OK

contains

  subroutine foo_p (x)
    class(t), pointer, intent(in) :: x
  end subroutine

end

 NAG accepts line 13, while ifort/ifx say:

ifort-class-arg.f90(13): error #8300: If a dummy argument is allocatable or a pointer, and the dummy or its associated actual argument is polymorphic, both dummy and actual must be polymorphic with the same declared type or both must be unlimited polymorphic.   [XA]
  call foo_p (xa) ! Valid in F2018, but rejected
--------------^

 F2018:15.5.2.5  (Allocatable and pointer dummy variables) has a restriction in the 1st paragraph:

The requirements in this subclause apply to an actual argument with the ALLOCATABLE or POINTER attribute that corresponds to a dummy argument with the same attribute.

while F2008 had:

The requirements in this subclause apply to actual arguments that correspond to either allocatable or pointer dummy data objects.

Note the subtle change in wording between F2008 and F2018 (F2023 has the same text as F2018).

 

1 Reply
Barbara_P_Intel
Employee
431 Views

Thank you once again, @Harald1. My resident Fortran expert who can read and understand the standard agrees. I filed a bug report, CMPLRLLVM-53742. We'll let you know when it's fixed.



0 Kudos
Reply