This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/80046] New: Explicit interface required for at (1): pointer argument


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

            Bug ID: 80046
           Summary: Explicit interface required for  at (1): pointer
                    argument
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joachim.herb at gmx dot de
  Target Milestone: ---

This is a sibling bug report to
https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/720770

The following code does not compile with gfortran (and as reported above with
the newest versions of ifort). Nevertheless, I think it should be valid code.
Here it is:

module impl_list__
  implicit none

  type, public :: Node_t
    integer :: val
    procedure(), nopass, pointer :: cloneProc_int
  end type

  interface
    subroutine NodeCloner( tgt, src )
      import Node_t
      type(Node_t), pointer, intent(out) :: tgt
      type(Node_t),           intent(in) :: src
    end subroutine
  end interface

  procedure(), pointer :: cloneProc => null()
  type(Node_t) :: node

end module

  subroutine func()
    use impl_list__
    implicit none
    procedure(NodeCloner), pointer :: cloneNode, cloneNode_int

    cloneNode_int => node%cloneProc_int
    cloneNode => cloneProc
  end subroutine

The compilation with gfortran results in the following error message (tested
with different versions: 5.2.0, 5.4.0, 7.0.0 20161030):

~/winhpc> gfortran --version
GNU Fortran (GCC) 7.0.0 20161030 (experimental)
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

~/winhpc> gfortran -c list_test_v2.f90
list_test_v2.f90:29:17:

     cloneNode => cloneProc
                 1
Error: Explicit interface required for 'cloneproc' at (1): pointer argument

The code tests the use of two procedure pointers. One is stored inside a user
defined type, the other is defined within the module. gfortran in all version
accepts the pointer inside the user defined type but not the one defined
directly in the module. Ifort before version 17.0.0 accepts both pointers. The
compilation fails for both pointers if the version is 17.0.0 or newer (also
tested 17.0.2).

~/winhpc> ifort --version
ifort (IFORT) 17.0.0 20160721
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

~/winhpc> ifort -c list_test_v2.f90
list_test_v2.f90(28): error #6138: An explicit interface is required in this
context.   [CLONENODE_INT]
    cloneNode_int => node%cloneProc_int
----^
list_test_v2.f90(29): error #6138: An explicit interface is required in this
context.   [CLONENODE]
    cloneNode => cloneProc
----^
compilation aborted for list_test_v2.f90 (code 1)


Is this an intended behavior? If so, what would be the correct way to handle
such pointers? Otherwise, is this a bug?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]