https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82312
Bug ID: 82312 Summary: Pointer assignment to component of class variable results wrong vptr for the variable. Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: pault at gcc dot gnu.org Target Milestone: --- Posted on Stack Overflow: https://stackoverflow.com/questions/46369744/gfortran-associates-wrong-type-bound-procedure/46388339#46388339 module minimalisticcase implicit none type, public :: DataStructure integer :: i contains procedure, pass :: init => init_data_structure procedure, pass :: a => beginning_of_alphabet end type type, public :: DataLogger type(DataStructure), pointer :: data_structure contains procedure, pass :: init => init_data_logger procedure, pass :: do_something => do_something end type contains subroutine init_data_structure(self) implicit none class(DataStructure), intent(inout) :: self write(*,*) 'init_data_structure' end subroutine subroutine beginning_of_alphabet(self) implicit none class(DataStructure), intent(inout) :: self write(*,*) 'beginning_of_alphabet' end subroutine subroutine init_data_logger(self, data_structure) implicit none class(DataLogger), intent(inout) :: self class(DataStructure), target :: data_structure write(*,*) 'init_data_logger' self%data_structure => data_structure call self%do_something() end subroutine subroutine do_something(self) implicit none class(DataLogger), intent(inout) :: self write(*,*) 'do_something' end subroutine end module program main use minimalisticcase implicit none type(DataStructure) :: data_structure type(DataLogger) :: data_logger call data_structure%init() call data_logger%init(data_structure) end program produces init_data_structure init_data_logger beginning_of_alphabet rather than init_data_structure init_data_logger do_something The tree dump reveals that the vptr of 'self' is being set to the address of the 'DataStructure' vtable. Paul