https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111477
Bug ID: 111477
Summary: Procedure as actual argument fails against procedure
pointer dummy argument
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: matthew.hambley at metoffice dot gov.uk
Target Milestone: ---
Test case:
> program test
>
> implicit none
>
> abstract interface
> subroutine one_if()
> implicit none
> end subroutine one_if
> end interface
>
> procedure(one_if), pointer :: one_ptr => null()
>
> call one_proc( first )
> one_ptr => first
> call one_proc( one_ptr )
>
> contains
>
> subroutine first()
> implicit none
> end subroutine first
>
> subroutine one_proc( one )
>
> implicit none
>
> procedure(one_if), pointer, intent(in) :: one
>
> call one()
>
> end subroutine one_proc
>
> end program test
This fails to compile the call to "one_proc( first )" but succeedes on the call
to "one_proc( one_ptr )".
Consulting with BS ISO/IEC 1539-1:2010 section 12.5.2.9 "Actual arguments
associated with dummy procedure entities", paragraph 5 says:
"If a dummy argument is a procedure pointer, the corresponding actual argument
shall be a procedure pointer, a reference to a function that returns a
procedure pointer, a reference to the intrinsic function NULL, or a valid
target for the dummy pointer in a pointer assignment statement."
It seems like a procedure with the correct calling signature should be "a valid
target for the dummy pointer" and so it seems like both call forms should work.
Maybe someone has a more recent version of the standard which clarifies this or
maybe I've misunderstood the very dense standard-speak.
For reference both Intel and IBM Fortrans do accept both call forms shown
above.