This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/44131] New: Using polymorfism in modules unware of derived types fails at run-time
- From: "klaas_giesbertz at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 May 2010 05:14:41 -0000
- Subject: [Bug fortran/44131] New: Using polymorfism in modules unware of derived types fails at run-time
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This problem is best illustrated by the following piece of code
module BaseModule
type, abstract :: BaseType
contains
procedure (DoAbstract), deferred, pass :: DoIt
end type
abstract interface
subroutine DoAbstract(self)
! import :: BaseType
class(BaseType) :: self
end subroutine
end interface
end module
module DerivedModule
use BaseModule
! use DerivedModule
type, extends(BaseType) :: DerivedType
contains
procedure :: DoIt => DoDerived
end type
contains
subroutine DoDerived(self)
class(DerivedType) :: self
print *, "Derived DoIt"
end subroutine
end module
module UseTypes
use BaseModule
contains
subroutine UseBaseOrDerived(someType)
class(BaseType) :: someType
call someType%DoIt()
end subroutine
end module
program Test
use BaseModule
use DerivedModule
use UseTypes
class(BaseType), allocatable :: someType
allocate(DerivedType :: someType)
call UseBaseOrDerived(someType)
end program
The subroutine useTypes should only need to know about the BaseType. The code
compiles perfectly without warning. However, at run-time, I get the following
error message:
At line 38 of file test.f03
Fortran runtime error: internal error: bad hash value in dynamic dispatch
However, if I uncomment use DerivedModule in the UseTypes module, everything
works fine. I also tried to compile this code with the xlf compiler 11.1. In
that case I need to uncomment the import statement in the abstract interface to
make it compile. However, it compiles and runs without the explicit declaration
of the DerivedType in the UseTypes module.
--
Summary: Using polymorfism in modules unware of derived types
fails at run-time
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: klaas_giesbertz at hotmail dot com
GCC host triplet: x86_64-apple-darwin10
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44131