https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38220

Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |burnus at gcc dot gnu.org,
                   |                            |Joost.VandeVondele at mat dot 
ethz
                   |                            |.ch
         Resolution|FIXED                       |---

--- Comment #6 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 
---
I believe this introduced a regression, C_LOC is not pure. 

Just quoting from here https://software.intel.com/en-us/forums/topic/269061

The "standard intrinsic procedures" are those listed in section 13.7 of F2003.
Procedures in intrinsic modules are not included. I happen to be writing this
from a meeting of the Fortran standards committee (J3) and posed this question
- the response from one member was "because we forgot to issue the Ivory Soap
certificates". None of the procedures in ISO_C_BINDING are pure.

The example why this restriction is a good idea (inspired by PR64247) is the
fact that if it where, any pure procedure could return different results even
if the variables have the same value (as opposed to address):

!
! are functions containing C_LOC pure ?
!
MODULE M1
CONTAINS
  PURE INTEGER*8 FUNCTION F(a) RESULT(I)
   USE ISO_C_BINDING, ONLY: C_LOC
   INTEGER*8, INTENT(IN), TARGET :: a
   I=TRANSFER(C_LOC(a),I)
  END FUNCTION
END MODULE M1

PROGRAM TEST
 USE M1
 INTEGER*8 :: i,ri
 INTEGER*8 :: j,rj
 i=4 ; j=4
 ri=F(i)
 rj=F(j)
 IF (ri.NE.rj) CALL ABORT()
END PROGRAM

ifort rejects this code, gfortran and cft compile but trigger the runtime
abort, pgf90 compiles and runs without abort.

CCing Tobias as he approved the patch...

Reply via email to