- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Responding to this, I got a little surprise. With the following
[fortran]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
[/fortran]
the compiler complains about the purity of sin. Why?
[plain]>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"?
-----------^[/plain]
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).
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Steve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We've fixed this for a future release.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page