Reported by Salvatore at http://gcc.gnu.org/ml/fortran/2010-08/msg00351.html.
Here is a slightly simplified version of the test case: module base_mat_mod type :: base_sparse_mat contains procedure, pass(a) :: get_fmt => base_get_fmt end type base_sparse_mat contains function base_get_fmt(a) result(res) implicit none class(base_sparse_mat), intent(in) :: a character(len=5) :: res res = 'NULL' end function base_get_fmt end module base_mat_mod module d_base_mat_mod use base_mat_mod type, extends(base_sparse_mat) :: d_base_sparse_mat contains procedure, pass(a) :: get_fmt => d_base_get_fmt end type d_base_sparse_mat type, extends(d_base_sparse_mat) :: x_base_sparse_mat contains procedure, pass(a) :: get_fmt => x_base_get_fmt end type x_base_sparse_mat contains function d_base_get_fmt(a) result(res) implicit none class(d_base_sparse_mat), intent(in) :: a character(len=5) :: res res = 'DBASE' end function d_base_get_fmt function x_base_get_fmt(a) result(res) implicit none class(x_base_sparse_mat), intent(in) :: a character(len=5) :: res res = 'XBASE' end function x_base_get_fmt end module d_base_mat_mod program bug20 use d_base_mat_mod class(d_base_sparse_mat), allocatable :: a allocate(x_base_sparse_mat :: a) write(0,*) 'Dynamic type on entry: ',a%get_fmt() select type(a) type is (d_base_sparse_mat) write(0,*) 'Dynamic type TYPE IS clause: ',a%get_fmt() class default write(0,*) 'Dynamic type CLASS DEFAULT clause: ',a%get_fmt() end select end program bug20 Current output: Dynamic type on entry: XBASE Dynamic type CLASS DEFAULT clause: DBASE Expected output: Dynamic type on entry: XBASE Dynamic type CLASS DEFAULT clause: XBASE -- Summary: [OOP] poylmorphic TBP calls in a CLASS DEFAULT clause Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: janus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45420