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

Passing a NULL() actual argument to a generic procedure

OP1
New Contributor III
255 Views

A colleague brought up the following code, for which the latest compiler (ifx 2024.2.0) issues an error message when trying to compile line 36: "error #8486: There is no matching specific subroutine for this type bound generic subroutine call. [G]" 

The fortran standard says in section 16.9.155 NULL([MOLD]) : "If the context of the reference to NULL is an actual argument in a generic procedure reference, MOLD shall be present if the type, type parameters, or rank are required to resolve the generic reference."

In this example, there is only one specific procedure, and thus resolving the generic interface should be possible even if NULL() is passed as argument to the generic procedure.

Could this be a bug in the compiler?

 

MODULE M
IMPLICIT NONE (TYPE, EXTERNAL)
TYPE :: T1
    CONTAINS
        PROCEDURE, PUBLIC :: P
        GENERIC, PUBLIC :: G => P
END TYPE T1
TYPE :: T2
END TYPE T2
CONTAINS
    SUBROUTINE P(SELF, O_T2)
        CLASS(T1)  :: SELF
        CLASS(T2), POINTER :: O_T2
    END SUBROUTINE P
END MODULE M

 
PROGRAM P
USE :: M 
IMPLICIT NONE (TYPE, EXTERNAL)
TYPE(T1) :: O_T1
CLASS(T2), POINTER :: O_T2 => NULL()

! All those calls with the specific subroutine P
! can be compiled.

CALL O_T1%P(O_T2)
CALL O_T1%P(NULL(O_T2))
CALL O_T1%P(NULL())

! When using the generic procedure G, the 3rd 
! CALL statement below cannot be compiled.

CALL O_T1%G(O_T2)
CALL O_T1%G(NULL(O_T2))
CALL O_T1%G(NULL()) ! Compiler issues an error. But should it?

END PROGRAM P
 

 

1 Reply
Devorah_H_Intel
Moderator
94 Views

This case is escalated to compiler engineering for further investigation and a fix. 

0 Kudos
Reply