Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Honored Contributor I
31 Views

Unexpected error #8191: The procedure target must be a procedure or a procedure pointer

Consider the following code:

module m

   implicit none

   abstract interface
      function I_f() result( j )
         integer :: j
      end function I_f
   end interface

   type :: t
      procedure(I_f), nopass, pointer :: m_f => null()
   contains
      procedure, pass(this) :: f => get_f
   end type t

contains

   function get_f( this ) result( f_ptr )

      class(t), intent(in)    :: this
      procedure(I_f), pointer :: f_ptr

      f_ptr => this%m_f

      return

   end function get_f

end module m
program p

   use m, only : t, I_f

   implicit none

   procedure(I_f), pointer :: f_ptr
   type(t) :: foo

   f_ptr => foo%f()

   stop

end program p

Compiler 17 processes the module code without any complaints, but gives an unexpected error with the main program:

1>Compiling with Intel(R) Visual Fortran Compiler 17.0.0.109 [IA-32]...
1>m.f90
1>p.f90
1>p.f90(10): error #8191: The procedure target must be a procedure or a procedure pointer.
1>ifort: error #10298: problem during post processing of parallel object compilation

 

0 Kudos
5 Replies
Highlighted
31 Views

We don't fully support functions that return procedure pointers - it's one of the missing F2008 items listed here. This error is a fallout from that.

0 Kudos
Highlighted
Honored Contributor I
31 Views

Steve Lionel (Intel) wrote:

We don't fully support functions that return procedure pointers - it's one of the missing F2008 items listed here. This error is a fallout from that.

Steve,

Thanks for your post.

May I please request someone from the Intel Fortran team to recheck: I feel the link you provide above has some information that appears incorrect.  Looking at the standard documents, my read is "functions that return procedure pointers" is a Fortran 2003 feature, not Fortran 2008.  Note John Reid wrote back in 2004, "A function may have a procedure pointer result"

Looking at the Fortran 2008 standard document, the enhancement is "pointer function reference can denote a variable in any variable definition context" toward the item in the above link that has "Pointer functions on left side of assignment statement" such as f(i) = 5 where f is pointer to a function that accepts the type of i as argument.  But since the code in the original post is not doing so, can one not expect a Fortran 2003 compiler to support it?

The above link states, "As of compiler version 16.0 (Intel® Parallel Studio XE 2016), the Intel® [Visual] Fortran compiler is fully compliant with the ISO/IEC 1539-1:2004 Fortran language standard (Fortran 2003 Language)," which is what raised my expectation with the code in the original post  Or if the feature is not supported, shouldn't it catch it at the source, meaning compilation of module m itself should flag an error?  

Thanks,

0 Kudos
Highlighted
31 Views

Any error here was mine. I will investigate further.

0 Kudos
Highlighted
31 Views

Very interesting. We had this tagged in our list as a F08 feature and we had not finished it yet. But you're right, it's actually a F03 feature. Curiously, your version of the function itself compiles ok but others give a "not yet implemented" message.

I have converted the "feature request" to a defect report, issue ID is DPD200517332. Thanks for the nudge.

0 Kudos
Highlighted
Honored Contributor I
31 Views

Thanks a bunch, Steve.  Here's a variation that unfortunately results in an ICE, if you don't mind passing that along to development:

module m

   implicit none

   abstract interface
      function I_f() result( j )
         integer :: j
      end function I_f
   end interface

   procedure(I_f), pointer :: f

contains

   function get_f() result( f_ptr )

      procedure(I_f), pointer :: f_ptr

      f_ptr => f

      return

   end function get_f

end module m
program p

   use m, only : I_f, get_f

   implicit none

   procedure(I_f), pointer :: f_ptr

   f_ptr => get_f

   stop

end program p
Compiling with Intel(R) Visual Fortran Compiler 17.0.0.109 [IA-32]...
p.f90
fortcom: Fatal: There has been an internal compiler error (C0000005).
ifort: error #10298: problem during post processing of parallel object compilation
compilation aborted for p.f90 (code 1)

 

0 Kudos