https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114020
--- Comment #1 from anlauf at gcc dot gnu.org --- (In reply to kargls from comment #0) > Found with the Fujitsu testsuite. Reduced testcase. > Note, if the use of ENTRY is replace with an actual > function, ie., 'function kmr_fixfun() result(zz)" the > code compiles and executes correctly. But is the original code valid? I am struggling with the standard text here. F2023:15.6.2.6 ENTRY statement C1583 (R1544) If RESULT appears, result-name shall not be the same as the function-name in the FUNCTION statement and shall not be the same as the entry-name in any ENTRY statement in the subprogram. Q: So does this allow identical RESULT() specifications? Paragraph 3: "... If the characteristics of the result of the function named in the ENTRY statement are the same as the characteristics of the result of the function named in the FUNCTION statement, their result names identify the same entity, although their names need not be the same. Otherwise, they are storage associated and shall all be nonpointer, nonallocatable scalar variables that are default integer, default real, double precision real, default complex, or default logical." Q: does this mean that function pointers, or other pointer variables in particular may have the same name, as in the sample code? Consider: function kmr_fixfun2() result(zz) implicit none entry kmr_fixfun() result(zz) real, pointer :: zz zz => null() end function This is accepted by gfortran and Intel; NAG complains: NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7200 Error: pr114020-z1.f90, line 6: Implicit type for KMR_FIXFUN in KMR_FIXFUN2 Reversing the entry statement and the declaration of zz makes NAG accept the code. Next: function kmr_fixfun2() result(zz) implicit none entry kmr_fixfun() result(zz) procedure(), pointer :: zz zz => null() end function This ICEs the same with gfortran as in comment#0. Intel: pr114020-z2.f90(4): error #6406: Conflicting attributes or multiple declaration of name. [ZZ] procedure(), pointer :: zz --------------------------^ pr114020-z2.f90(3): error #6404: This name does not have a type, and must have an explicit type. [KMR_FIXFUN] entry kmr_fixfun() result(zz) --------^ pr114020-z2.f90(1): error #6404: This name does not have a type, and must have an explicit type. [KMR_FIXFUN2] function kmr_fixfun2() result(zz) ---------^ NAG: NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7200 Error: pr114020-z2.f90, line 6: Implicit type for KMR_FIXFUN in KMR_FIXFUN2 This is consistent with the real pointer. Again, reversion the entry statement and the declaration of zz: function kmr_fixfun2() result(zz) implicit none procedure(), pointer :: zz entry kmr_fixfun() result(zz) zz => null() end function Again ICE with gfortran, and same error with Intel as above. NAG: NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7200 Error: pr114020-z2.f90, line 4: Inappropriate use of symbol ZZ detected at (@ZZ Error: pr114020-z2.f90, line 4: RESULT clause is not allowed in a SUBROUTINE detected at ZZ@) Nvidia crashes, too. AMD flang prints in the latter case: F90-S-0043-Illegal attempt to redefine symbol zz (pr114020-z2.f90: 4)