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/78737] [OOP] linking error with deferred, undefined user-defined derived-type I/O


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

--- Comment #6 from Damian Rouson <damian at sourceryinstitute dot org> ---
Janus, thanks for your additional investigation and comments.

Jerry, below is a better example in which I extend the abstract type and
implement the deferred binding in the non-abstract child type but invoke the
UDDTIO procedure via the deferred binding.  I still get the same linking error.
Deleting the "write(*,*) a" statement eliminates the linking error, but doing
also would also prevent an important element of my intended usage of UDDTIO.


$ cat undefined-ud-dtio.f90 
module object_interface
  type, abstract :: object
  contains
    procedure(write_formatted_interface), deferred ::write_formatted 
    generic :: write(formatted)=>write_formatted
  end type 
  abstract interface
    subroutine write_formatted_interface(this,unit,iotype,vlist,iostat,iomsg)
      import object
      class(object), intent(in) :: this
      integer, intent(in) :: unit
      character (len=*), intent(in) :: iotype
      integer, intent(in) :: vlist(:)
      integer, intent(out) :: iostat
      character (len=*), intent(inout) :: iomsg
    end subroutine
  end interface
  type, extends(object) :: non_abstract_child 
  contains
    procedure :: write_formatted
  end type
contains
  subroutine write_formatted(this,unit,iotype,vlist,iostat,iomsg)
    class(non_abstract_child), intent(in) :: this
    integer, intent(in) :: unit
    character (len=*), intent(in) :: iotype
    integer, intent(in) :: vlist(:)
    integer, intent(out) :: iostat
    character (len=*), intent(inout) :: iomsg
  end subroutine
  subroutine assert(a)
    class(object):: a
    write(*,*) a 
  end subroutine
end module

end

$ gfortran undefined-ud-dtio.f90 
Undefined symbols for architecture x86_64:
  "_write_formatted_interface_", referenced from:
      ___object_interface_MOD_assert in ccXYfdSK.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

$ gfortran --version
GNU Fortran (MacPorts gcc7 7-20161204_0) 7.0.0 20161204 (experimental)

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