• Procedure pointer initialization

    From James Van Buskirk@21:1/5 to All on Sun May 22 01:54:29 2022
    I think my example is a syntactically correct instance of procedure
    pointer initialization but both gfortran and an old version of ifort
    error out on it:

    module funcs
    implicit none
    interface
    subroutine a() bind(C,name='a1')
    implicit none
    end subroutine a
    subroutine b() bind(C,name='a2')
    implicit none
    end subroutine b
    end interface
    end module funcs

    program start
    use funcs
    implicit none
    type has_fun
    procedure(a), pointer, nopass :: fun
    end type has_fun
    type(has_fun) :: lots(2) = [has_fun(a),has_fun(b)]
    procedure(a), pointer :: stuff => b
    end program start

    subroutine c() bind(C,name='a1')
    implicit none
    end subroutine c

    subroutine d() bind(C,name='a2')
    implicit none
    end subroutine d

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JRR@21:1/5 to All on Mon May 23 10:52:56 2022
    Hi James,
    indeed, the code looks standard-conforming to me. The problem is the initialization of lots, using of array of objects built by structure constructors. gfortran and ifort complain that they don't know what
    a is, so they can't resolve the interfaces from module funcs, nagfor
    compiles without complaints. If you use
    type(has_fun), dimension(2) :: lots
    [...]
    lots = [has_fun(a), has_fun(b)]

    gfortran compiles this as well, while ifort 2021.5.0 produces an ICE.
    You should report this to gfortran and Intel.
    Cheers,
    JRR

    Am 22.05.22 um 09:54 schrieb James Van Buskirk:
    I think my example is a syntactically correct instance of procedure
    pointer initialization but both gfortran and an old version of ifort
    error out on it:

    module funcs
      implicit none
      interface
         subroutine a() bind(C,name='a1')
            implicit none
         end subroutine a
         subroutine b() bind(C,name='a2')
            implicit none
         end subroutine b
      end interface
    end module funcs

    program start
      use funcs
      implicit none
      type has_fun
         procedure(a), pointer, nopass :: fun
      end type has_fun
      type(has_fun) :: lots(2) = [has_fun(a),has_fun(b)]
      procedure(a), pointer :: stuff => b
    end program start

    subroutine c() bind(C,name='a1')
      implicit none
    end subroutine c

    subroutine d() bind(C,name='a2')
      implicit none
    end subroutine d



    --
    Juergen Reuter
    Theoretical Particle Physics
    Deutsches Elektronen-Synchrotron (DESY)
    Hamburg, Germany

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)