Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor II

Internal compiler error for module function with pointer return

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
Highlighted
Valued Contributor II

But

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
Highlighted
Employee

Thank you for reporting this

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
Highlighted
Valued Contributor III

Kevin,

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
Highlighted
Employee

Thank you FortranFan. I

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