https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67471
Bug ID: 67471 Summary: Finalizer not invoked for assignment to array section Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: ian_harvey at bigpond dot com Target Milestone: --- gfortran recent trunk r227512 does not invoke the finalizer for the intrinsic assignment (as required by F2008 4.5.6.3p9) to the array section of `b` in the following example: module tes_final_mod implicit none type :: my_final integer :: n = 0 contains final :: destroy_rank1_array end type my_final contains subroutine destroy_rank1_array(self) type(my_final), intent(inout) :: self(:) if (size(self) /= 0) then print "(A,I0,A,*(I0,:,', '))", & 'destroy_rank1_array executed for object of size ', & size(self), & ' and component values ', & self%n else print "(A)", & 'destroy_rank1_array executed for object of size 0' end if end subroutine destroy_rank1_array end module tes_final_mod program test_finalizer use tes_final_mod implicit none type(my_final) :: b(4), c(2) b%n = 2 c%n = 3 b(1:2) = c end program test_finalizer No output is generated, while expected output is: destroy_rank1_array executed for object of size 2 and component values 2,2 See also https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/591918#comment-1838428