Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

SegFault with REAL128 conversion

holysword
Novice
670 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
Honored Contributor III
670 Views

Try attributing out with 16 byte alignment.

 !DIR$ ATTRIBUTES ALIGN: 16 :: out

Jim Dempsey

0 Kudos
Steven_L_Intel1
Employee
670 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.

0 Kudos
Reply