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

Internal compiler error for module function with pointer return

Andrew_Smith
New Contributor III
287 Views

This code re-produces:

module A
   implicit none
   interface
      pure real module function getItem(id) result(res)
         integer, intent(in) :: id
         pointer :: res
      end
   end interface
   real, target :: items(10)
end module

submodule(A) A1
   implicit none
contains
   pure real module function getItem(id) result(res)
      integer, intent(in) :: id
      pointer :: res
      res => items(id)
   end
end submodule

 

0 Kudos
4 Replies
andrew_4619
Honored Contributor II
287 Views

But

module A
   implicit none
   interface
       pure module function getItem(id)  
         integer, intent(in) :: id
         real, pointer :: getItem
      end function getItem
   end interface
   real, target :: items(10)
end module
submodule(A) A1
   implicit none
   contains
   module procedure getItem 
        getItem => items(id)
   end procedure getItem
end submodule

this form does not have an ICE or Compile errors.... I do not like to use this form BTW

0 Kudos
Kevin_D_Intel
Employee
287 Views

Thank you for reporting this and for the convenient reproducer. It reproduces with current (17.0) and previous (16.0) compilers. I reported it to Development.

(Internal tracking id: DPD200418366)

0 Kudos
FortranFan
Honored Contributor II
287 Views

Kevin,

Please note also the "module procedure" variant by Andrew in Message #2 should throw a compiler error about the invalid pointer assignment in a PURE procedure.  Intel Fortran compiler misses out on it, can you please investigate and followup as needed?

Thanks much,

 

0 Kudos
Kevin_D_Intel
Employee
287 Views

Thank you FortranFan. I submitted that one also. I was wondering about that earlier in regard to the original case too.

(Internal tracking id: DPD200418373 - Missing error for invalid pointer assignment in a PURE procedure)

0 Kudos
Reply