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

--- Comment #2 from kargls at comcast dot net ---
(In reply to anlauf from comment #1)
> (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?

Not sure if its valid or invalid.  It certainly should not cause an ICE.

> 
> 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.

This constraint seems to be met as all three are different.
result-name is 'zz', function-name is 'kmr_fixfun2', and
entry-name is 'kmr_fixfun'

> Q: So does this allow identical RESULT() specifications?

I think the answer is 'yes'

> 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.

I think the above is the key. Not only are the characteristics
of the result the same, the result-name is the same.  Changing the
original code to have distinct result-names does not help

   function kmr_fixfun2() result(zz)
      procedure(sub), pointer :: yy, zz
      zz => null()
      return
      entry kmr_fixfun() result(yy)
      yy => null()
   end function 

> 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?

I think so, but even using different result names causes problems.

Reply via email to