Pureness of intrinsic specific functions

Pureness of intrinsic specific functions

Responding to this, I got a little surprise.  With the following

MODULE m
  IMPLICIT NONE
CONTAINS
  SUBROUTINE sub(proc)
    INTERFACE
      PURE FUNCTION proc(x)
        IMPLICIT NONE
        REAL, INTENT(IN) :: x
        REAL :: proc
      END FUNCTION proc
    END INTERFACE
    PRINT *, proc(0.0)
  END SUBROUTINE sub
END MODULE m
PROGRAM p
  USE m
  IMPLICIT NONE
  INTRINSIC :: sin
  CALL sub(sin)       ! <-- Why "argument must be pure"?
END PROGRAM p

the compiler complains about the purity of sin.  Why?

>ifort /check:all /warn:all /standard-semantics passing-intrinsic.f90 && passing-intrinsic.exe
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.0.103 Build 20130728
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.
passing-intrinsic.f90(20): error #7892: Procedure argument must be PURE   [SIN]
  CALL sub(sin)       ! <-- Why "argument must be pure"?
-----------^

This is unfamiliar territory for me, and ifort isn't alone in its complaint (gfortran complains too), so that makes me wonder what I've missed.

- "All standard intrinsic functions are pure" - F2008 13.1 p2.

- "If the interface of a dummy proceure is explicit, its characteristics as a procedure shall be the same as those of its effective argument, except... an elemental intrinsic actual procedure may be associated with a dummy procedure (which cannot be elemental)." - F2008 12.5.2.9 p1

- In F2008 13.6 the specific `sin` doesn't have a dot, so it can be an actual arg (F2008 C1235 and 12.5.2.9 p4).

5 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

As best as I can tell, your example should work. I will let the developers know. Feel free to report this to the gfortran devs too. Our issue ID is DPD200248826.

Steve - Intel Developer Support

Thank you Steve.

We've fixed this for a future release.

Steve - Intel Developer Support

Great!

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi