[Bug fortran/77596] [F03] procedure pointer with implicit interface in type pointing to a function can be 'called'

janus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Nov 6 15:56:00 GMT 2016


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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
             Status|WAITING                     |NEW
                 CC|                            |janus at gcc dot gnu.org

--- Comment #2 from janus at gcc dot gnu.org ---
(In reply to toK from comment #0)
> I guess that in an ideal world, the compiler should generate code to cause a
> run-time error in a situation like in the following snippet:

It should already be rejected at compile time, I think. When using "implicit
none", a "procedure(), pointer" can only point to a subroutine, IIRC.


Slightly modified example (with a plain procedure pointer instead of a PPC):


program xxx
  implicit none
  call ass()

contains

  function ff(x)
    integer, intent(in) :: x
    integer :: ff
    print *, 'aaaa'
  end function ff

  subroutine ass()
    procedure(), pointer :: fp
    fp=>ff
    call fp(3)
  end subroutine ass

end program xxx


This is correctly rejected with:

     fp=>ff
        1
Error: Interface mismatch in procedure pointer assignment at (1): 'ff' is not a
subroutine


More information about the Gcc-bugs mailing list