Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

SegFault with REAL128 conversion

holysword
Beginner
161 Views

The following code

PROGRAM test_stuff
  USE, INTRINSIC :: ISO_FORTRAN_ENV
  
  IMPLICIT NONE

  INTEGER(KIND=INT8) :: ivar1
  REAL(KIND=REAL128) :: rvar1
  
  PRINT *,"real128: ", real128
  ivar1 = 9
  rvar1 = cnv_real128(ivar1)
  
  CONTAINS
  
  FUNCTION cnv_real128(icls) RESULT(out)
    CLASS(*), INTENT(IN)  :: icls
    REAL(KIND=REAL128), ALLOCATABLE :: out
    ALLOCATE(out)
    SELECT TYPE(icls)
        TYPE IS (INTEGER(KIND=INT8))
        out = REAL(icls, KIND=REAL128)
      CLASS DEFAULT
        out = REAL(0.0,KIND=REAL128)
    END SELECT
  END FUNCTION cnv_real128
END PROGRAM test_stuff

gives me a segmentation fault at runtime. Replacing REAL128 with REAL64 gives me no error. I've tried with ifort-16.0 and 17.0. Is this somehow expected?

Thanks in advance!

0 Kudos
2 Replies
jimdempseyatthecove
Black Belt
161 Views

Try attributing out with 16 byte alignment.

 !DIR$ ATTRIBUTES ALIGN: 16 :: out

Jim Dempsey

Steven_L_Intel1
Employee
161 Views

The problem is caused by the function result being ALLOCATABLE and REAL128 - something is going very wrong there and I'll create a bug report for it. If OUT is not ALLOCATABLE, it works fine. Issue ID is DPD200415360.

Reply