https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78737
Bug ID: 78737
Summary: linking error with deferred, undefined user-defined
derived-type I/O
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: damian at sourceryinstitute dot org
Target Milestone: ---
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
rouson@localhost:~/xfr$ 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.