https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38220
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution|--- |FIXED
--- Comment #11 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #9)
> (In reply to Joost VandeVondele from comment #6)
> > ifort rejects this code, gfortran and cft compile but trigger the runtime
> > abort, pgf90 compiles and runs without abort.
>
> Actually that code has the logic wrong. Adjusted, portable testcase:
>
> MODULE M1
> CONTAINS
> PURE INTEGER(C_INTPTR_T) FUNCTION F(a) RESULT(I)
> USE ISO_C_BINDING, ONLY: C_LOC, C_INTPTR_T
> INTEGER, INTENT(IN), TARGET :: a
> I=TRANSFER(C_LOC(a),I)
> END FUNCTION
> END MODULE M1
>
> PROGRAM TEST
> USE M1
> USE ISO_C_BINDING, ONLY: C_INTPTR_T
> INTEGER :: i, j
> integer(C_INTPTR_T) :: ri, rj
> i=4 ; j=4
> ri=F(i)
> rj=F(j)
> IF (ri == rj) stop 1
> rj=F(i)
> IF (ri /= rj) stop 2
> END PROGRAM
>
> Works with Crayftn 14.0, Intel, Nvidia, gfortran.
>
> Wrong code with flang.
>
> Rejected by NAG with:
>
> NAG Fortran Compiler Release 7.1(Hanzomon) Build 7101
> Error: pr38220.f90, line 9: Reference via generic C_LOC to impure
> C_LOC_PRIVATE from pure F
Update: NAG Build 7200 accepts the code, too.
> Can we close it again?
The issue has been fixed over 16 years ago - see comment#4 - thus closing.