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

Non-pointer real argument passed to a procedure expecting a pointer argument

OP1
New Contributor III
290 Views

The code below compiles with the latest ifx compiler (2025.1.0), but I am not sure it should. The Intel documentation states: 

"A dummy argument that is a pointer can be associated only with an actual argument that is a pointer.link 

Shouldn't the call to S1 on line 4 be illegal then, since P is not a pointer?

PROGRAM TEST
IMPLICIT NONE

CALL S1(P)
CALL S2(P)

CONTAINS

    SUBROUTINE P
    IMPLICIT NONE (TYPE, EXTERNAL)
    END SUBROUTINE P

    SUBROUTINE S1(PROC)
    IMPLICIT NONE (TYPE, EXTERNAL)
    PROCEDURE(P), POINTER, INTENT(IN) :: PROC
    END SUBROUTINE S1

    SUBROUTINE S2(PROC)
    IMPLICIT NONE (TYPE, EXTERNAL)
    PROCEDURE(P) :: PROC
    END SUBROUTINE S2

END PROGRAM TEST

 

0 Kudos
5 Replies
Steve_Lionel
Honored Contributor III
272 Views

The documentation has not been updated here to correspond with Fortran 2008, which allows a non-pointer to be passed to an INTENT(IN) pointer:

"If the dummy argument does not have the INTENT (IN), the actual argument shall be a pointer. Otherwise, the actual argument shall be a pointer or a valid target for the dummy pointer in a pointer assignment statement. If the actual argument is not a pointer, the dummy pointer becomes pointer associated with the actual argument." F2008 12.5.2.7 Pointer dummy variables

0 Kudos
OP1
New Contributor III
259 Views

Thanks Steve! @Devorah_H_Intel , this one is for your documentation crew!

Ron_Green
Moderator
185 Views

These days it's a crew of one sharing time with the C++ team. 

0 Kudos
Ron_Green
Moderator
180 Views

It looks like we caught this documentation error back in March.  the issue ID is DOC-13286.  I have added your report to the existing bug.  We'll see if we can get this done for the next release.  Thank you for bringing this to our attention.

JohnNichols
Valued Contributor III
149 Views

No matter how much we try the documentation will remain a century behind reality.    Snoopy's Coding Rule 1313

0 Kudos
Reply