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

Parameterized derived type and array-valued function returning component data: strange compiler behavior

FortranFan
Honored Contributor III
759 Views

Another strange one with parameterized derived types: the following simple code results in a compiler error,  incorrectly in my opinion.  But simply uncommenting the unrelated lines 17-26 makes the code compile ok:

module m

   implicit none

   private

   type, public :: t(n)
      private
      integer, len :: n = 1
      integer :: m_x(n)
   contains
      procedure, pass(this), public :: x => get_t_x
   end type t

contains

   !subroutine load_t_x(this, dat)
   !
   !   class(t(*)), intent(inout)               :: this
   !   integer(kind=kind(this%m_x)), intent(in) :: dat(:)
   !
   !   this%m_x = dat
   !
   !   return
   !
   !end subroutine load_t_x
   
   function get_t_x(this) result(retval)

      class(t(*)), intent(in) :: this
      !..
      integer(kind=kind(this%m_x)) :: retval(this%n)

      retval = this%m_x

      return

   end function get_t_x

end module m

The compiler output is:

------ Build started: Project: p, Configuration: Debug|x64 ------

Compiling with Intel(R) Visual Fortran Compiler XE 15.0.2.179 [Intel(R) 64]...
m.f90
C:\..\m.f90(32): error #6160: This component is not a field of the encompassing structure.   
compilation aborted for C:\..\m.f90 (code 1)

 

0 Kudos
2 Replies
Steven_L_Intel1
Employee
759 Views

Escalated as issue DPD200367089 - thanks.

0 Kudos
Steven_L_Intel1
Employee
759 Views

I expect this to be fixed in 16.0.1 (2016 Update 1)

0 Kudos
Reply