Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

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

$
0
0

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 ==========

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>