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

Parameterized derived type with type-bound procedure: unexpected run-time error [forrtl: severe (408): fort: (10)..]

FortranFan
Honored Contributor III
551 Views

The following simple code compiles with no errors or warnings, but generates a run-time error [forrtl: severe (408): fort: (10)..].  I think the code is alright, please correct me otherwise.

module m

   implicit none

   private

   type, public :: t(n)
      private
      integer, len :: n = 1
      integer :: m_x(n)
   contains
      procedure, pass(this), public :: load => load_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

end module m

program p

   use m, only : t

   type(t(n=2)) :: foo

   call foo%load( [ 1, 2 ] )

   stop

end program p

Upon execution,

forrtl: severe (408): fort: (10): Subscript #1 of the array M_X has value 1 whic
h is greater than the upper bound of 0

Image              PC                Routine            Line        Source

p.exe              000000013F9744B0  Unknown               Unknown  Unknown
p.exe              000000013F9710BD  M_mp_LOAD_T_X              22  m.f90
p.exe              000000013F971349  MAIN__                      7  p.f90
p.exe              000000013F99707E  Unknown               Unknown  Unknown
p.exe              000000013F997360  Unknown               Unknown  Unknown
kernel32.dll       00000000772359ED  Unknown               Unknown  Unknown
ntdll.dll          000000007736BA01  Unknown               Unknown  Unknown
Press any key to continue . . .

 

0 Kudos
3 Replies
Steven_L_Intel1
Employee
551 Views

From what I can see, it's only the bounds checking error that is the problem, as the assignment is otherwise done successfully. Escalated as issue DPD200367073. Thanks.

0 Kudos
FortranFan
Honored Contributor III
551 Views

Thanks Steve.  Yes, /check:bounds option was being used.  Now I have a workaround.

0 Kudos
Steven_L_Intel1
Employee
551 Views

I expect this to be fixed in Update 3, due in May.

0 Kudos
Reply