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

Internal Compiler Error with use of a parameterized derived type with type-bound procedures

FortranFan
Honored Contributor II
240 Views

This builds further on the code shown in the topic  https://software.intel.com/en-us/forums/topic/536578.  The use of the derived type in a program results in an internal compiler error:

MODULE m

   USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY : I4 => INT32, SP => REAL32, DP => REAL64

   IMPLICIT NONE

   !..
   PRIVATE

   !..
   PUBLIC :: I4, SP, DP

   TYPE, PUBLIC :: t(k,n)
      PRIVATE
      INTEGER(I4), KIND :: k = SP
      INTEGER(I4), LEN  :: n = 1
      REAL(k) :: m_X(n)
   CONTAINS
      PRIVATE
      PROCEDURE, PASS(This) :: GetX_SP
      PROCEDURE, PASS(This) :: GetX_DP
      PROCEDURE, PASS(This) :: SetX_SP
      PROCEDURE, PASS(This) :: SetX_DP
      GENERIC, PUBLIC :: X => GetX_SP, GetX_DP
      GENERIC, PUBLIC :: SetX => SetX_SP, SetX_DP
   END TYPE t

CONTAINS

   PURE FUNCTION GetX_SP(This) RESULT(RetVal)

      CLASS(t(SP,*)), INTENT(IN) :: This
      !.. Function result
      REAL(SP), ALLOCATABLE :: RetVal(:)

      RetVal = This%m_X

      RETURN

   END FUNCTION GetX_SP

   PURE FUNCTION GetX_DP(This) RESULT(RetVal)

      CLASS(t(DP,*)), INTENT(IN) :: This
      !.. Function result
      REAL(DP), ALLOCATABLE :: RetVal(:)

      RetVal = This%m_X

      RETURN

   END FUNCTION GetX_DP

   PURE SUBROUTINE SetX_SP(This, Arr)

      CLASS(t(SP,*)), INTENT(INOUT) :: This
      REAL(SP), INTENT(IN)          :: Arr(:)

      IF (SIZE(Arr) == This%n) THEN
         This%m_X = Arr
      END IF

      RETURN

   END SUBROUTINE SetX_SP

   PURE SUBROUTINE SetX_DP(This, Arr)

      CLASS(t(DP,*)), INTENT(INOUT) :: This
      REAL(DP), INTENT(IN)          :: Arr(:)

      IF (SIZE(Arr) == This%n) THEN
         This%m_X = Arr
      END IF

      RETURN

   END SUBROUTINE SetX_DP

END MODULE m

PROGRAM p

   USE m, ONLY : I4, DP, t

   IMPLICIT NONE

   !.. Local variables
   TYPE(t(DP,5)) :: foo
   REAL(DP) :: x(5)

   PRINT *, " Test #74: PDT"

   PRINT *, " foo%k = ", foo%k
   PRINT *, " foo%n = ", foo%n
   
   x = -1.0_dp
   CALL foo%SetX(x)
   PRINT *, " foo%x = ", foo%X()

   !..
   STOP

END PROGRAM p

 

1>------ Build started: Project: TestFor, Configuration: Debug Win32 ------
1>Unlock PDB file
1>Compiling resources...
1>TestFor.rc
1>Microsoft (R) Windows (R) Resource Compiler Version 6.3.9600.17298
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>Compiling with Intel(R) Visual Fortran Compiler XE 15.0.1.148 [IA-32]...
1>TestMod.f90
1>C:\..\TestMod.f90(56): warning #7026: Non-standard extension.   [T#4&*]
1>C:\..\TestMod.f90(69): warning #7026: Non-standard extension.   [T#8&*]
1>TestFor.f90
1>fortcom: Fatal: There has been an internal compiler error (C0000005).
1>compilation aborted for C:\..\TestFor.f90 (code 1)
1>
1>Build log written to  "file://C:\..\Debug\Win32\TestForBuildLog.htm"
1>TestFor - 1 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

0 Kudos
6 Replies
Steven_L_Intel1
Employee
240 Views

Thanks - we'll check it out.

0 Kudos
Steven_L_Intel1
Employee
240 Views

This looks to be the same as https://software.intel.com/en-us/forums/topic/535467 . Escalated as issue DPD200363307.

0 Kudos
Steven_L_Intel1
Employee
240 Views

This has been fixed in our sources. I expect the fix to appear in Update 2, planned for February.

0 Kudos
FortranFan
Honored Contributor II
240 Views

Steve Lionel (Intel) wrote:

This has been fixed in our sources. I expect the fix to appear in Update 2, planned for February.

Steve,

The code in the original post compiles fine now, but it generates run-time exception (as shown below) if /check:bounds compiler option is specified.  Any idea why?

  Test #74: PDT
  foo%k =  8
  foo%n =  5
forrtl: severe (408): fort: (2): Subscript #1 of the array M_X has value 1 which
 is greater than the upper bound of 0

Image              PC        Routine            Line        Source
TestFor32.exe      01284C54  Unknown               Unknown  Unknown
TestFor32.exe      012819F4  _M_mp_SETX_DP              73  TestMod.f90
TestFor32.exe      01281DA9  _MAIN__                    17  TestFor.f90
TestFor32.exe      012EEA62  Unknown               Unknown  Unknown
TestFor32.exe      012EF27A  Unknown               Unknown  Unknown
TestFor32.exe      012EF3CD  Unknown               Unknown  Unknown
kernel32.dll       76D9338A  Unknown               Unknown  Unknown
ntdll.dll          7795BF32  Unknown               Unknown  Unknown
ntdll.dll          7795BF05  Unknown               Unknown  Unknown
Press any key to continue . . .

 

0 Kudos
FortranFan
Honored Contributor II
240 Views

Possibly connected with https://software.intel.com/en-us/forums/topic/536334 and https://software.intel.com/en-us/forums/topic/536564?

0 Kudos
Steven_L_Intel1
Employee
240 Views

Very likely. I added your case to the report of that problem and asked the developers for an update.

0 Kudos
Reply