http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45900
Summary: [OOP] Polymorphic method not called Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: ort...@gmail.com The following example code provides an incorrect result using gfortran 4.6.0 20100925. I believe the code is valid and I have tested the same code with the Intel Fortran compiler (ifort) 11.1 on Linux and the results returned are correct. See the below example: types.f90 --------------------------------------------------------- module A implicit none type :: aType contains procedure :: callback end type aType contains subroutine callback( callback_ ) implicit none class(aType) :: callback_ print *, "Error: aType method called." end subroutine callback subroutine solver( callback_ ) implicit none class(aType) :: callback_ call callback_%callback() end subroutine solver end module A module B use A, only: aType implicit none type, extends(aType) :: bType integer :: i contains procedure :: callback end type bType contains subroutine callback( callback_ ) implicit none class(bType) :: callback_ print *, "Made it." end subroutine callback end module B program main use A use B implicit none type(bType) :: bTypeInstance integer :: iflag bTypeInstance%i = 4 call bTypeInstance%callback() call solver( bTypeInstance ) end program main --------------------------------------------------------- The result produced running this code are found to be: $ gfortran -o t types.f90 $ ./t Error: aType method called. Made it. While ifort correctly produces the result: Made it. Made it. A workaround is to do change "use A" in the main to: use A, only: solver Using built-in specs. COLLECT_GCC=gfortran Target: x86_64-apple-darwin10.4.0 Configured with: ../gcc-4.6-20100925/configure --prefix=~$HOME/gcc-trunk --enable-languages=fortran --enable-checking=release --disable-bootstrap Thread model: posix gcc version 4.6.0 20100925 (experimental) (GCC)