Compiler erroneously allows a procedure pointer to an elemental procedure.

Compiler erroneously allows a procedure pointer to an elemental procedure.

Consider the following simple example: the compiler (version 14 as well as 2015 BETA) allows a procedure pointer to an elemental procedure and based on what I understand, this is a violation of the standard.  So I request Intel staff to take a look and do the needful; my apologies if this issue has already been identified and a tracking incident is already in effect.

   MODULE m
   
      !..
      IMPLICIT NONE
   
      !..
      PRIVATE
      
      !.. Private fields
      INTEGER :: m_i1 = 1
      PROCEDURE(GetAbstract), POINTER :: Get
      
      !.. Public methods
      PUBLIC :: Set
   
      !.. Abstract Interface for a getter method
      ABSTRACT INTERFACE
   
         PURE ELEMENTAL FUNCTION GetAbstract() RESULT(RetVal)
            !.. Function result
            INTEGER :: RetVal
         END FUNCTION GetAbstract
   
      END INTERFACE
   
   CONTAINS
   
      PURE ELEMENTAL FUNCTION get_i1() RESULT(RetVal)
   
         !.. Function result
         INTEGER :: RetVal
   
         !..
         RetVal = m_i1
   
         !..
         RETURN
   
      END FUNCTION get_i1
   
      SUBROUTINE Set(qName)
   
         !.. Argument list
         CHARACTER(LEN=*), INTENT(IN) :: qName
         
         !..
         Get => NULL()
         IF (qName == "i1") THEN
            Get => get_i1
         END IF
   
         !..
         RETURN
   
      END SUBROUTINE Set
   
   END MODULE m

Thanks,

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

FWIW, gfortran 4.9 seems to flag this correctly as an error and gives sufficiently descriptive explanation:

gfortran.exe -JDebug\GNU\ -Wall -fall-intrinsics -g -std=f2008 -c sor\m.f90 -o Debug\GNU\sor\m.o
sor\m.f90:11.44:
      PROCEDURE(GetAbstract), POINTER :: Get
                                            1
Error: Procedure pointer 'get' at (1) shall not be elemental
sor\m.f90:48.19:
            Get => get_i1
                   1
Error: Nonintrinsic elemental procedure 'get_i1' is invalid in procedure pointer assignment at (1)
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))

 

I did not find any previous defect report about this so I set this to Development (see internal tracking id below) and will keep you informed on what I hear back.

(Internal tracking id: DPD200358641)

Thanks much, Kevin, for the follow-up.

 

Leave a Comment

Please sign in to add a comment. Not a member? Join today