Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Compiler fails to catch rank (and attribute) mismatch with the interface in procedure pointer assignment

FortranFan
Honored Contributor III
686 Views

The following simple code compiles with no errors or warnings with compiler 16.0, however the procedure pointer assignment at line 33 has a rank and allocatable attribute mismatch in function result.  It'll be nice if the compiler can warn about this.

module m

   implicit none

   abstract interface

      function Iget_i() result(iarr)

         !.. function result
         integer :: iarr

      end function Iget_i

   end interface

   procedure(Iget_i), pointer :: get => null()

contains

   function get_i() result(iarr)

      !..function result
      integer, allocatable :: iarr(:)

      iarr = [ 0 ]

      return

   end function get_i

   subroutine sub()

      get => get_i

   end subroutine sub

end module m

 

0 Kudos
3 Replies
FortranFan
Honored Contributor III
686 Views

Another variant of the interface mismatch problem:

module m

   implicit none

   abstract interface

      function Iget_i() result(iarr)

         !.. function result
         integer :: iarr(1)

      end function Iget_i

   end interface

   procedure(Iget_i), pointer :: get => null()

contains

   function get_i() result(iarr)

      !..function result
      integer, allocatable :: iarr(:)

      iarr = [ 0 ]

      return

   end function get_i

   subroutine sub()

      get => get_i

   end subroutine sub

end module m

 

0 Kudos
FortranFan
Honored Contributor III
686 Views

And a third:

module m

   implicit none

   abstract interface

      function Iget_i() result(iarr)

         !.. function result
         integer, allocatable :: iarr(:)

      end function Iget_i

   end interface

   procedure(Iget_i), pointer :: get => null()

contains

   function get_i() result(iarr)

      !..function result
      integer :: iarr(1)

      iarr = [ 0 ]

      return

   end function get_i

   subroutine sub()

      get => get_i

   end subroutine sub

end module m

 

0 Kudos
Kevin_D_Intel
Employee
686 Views

Thank you FortranFan. I submit these to Development for their consideration.

Updated 11/19/2015: Submitted to Development

(Internal tracking id: DPD200378947)

0 Kudos
Reply