This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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 78737 - linking error with deferred, undefined user-defined derived-type I/O


A linking error results when an abstract type defers a user-defined derived type output binding that is not implemented anywhere in the program:

$ 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
contains
  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 ccMQHXbf.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

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

Adding a type that defines the binding eliminates the linking error.


Damian


________________________________
Damian Rouson, Ph.D., P.E.
President, Sourcery Institute
http://www.sourceryinstitute.org
+1-510-600-2992 (mobile)


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