The following test case is a modified version of the one in http://gcc.gnu.org/ml/fortran/2009-10/msg00047.html:
implicit none type t0 integer :: j = 42 end type t0 type t integer :: i class(t0), allocatable :: foo end type t type(t) :: m allocate(t0 :: m%foo) m%i = 5 select type(bar => m%foo) type is(t0) print *, bar end select end While the original version (using allocatable CLASS arrays) still ICEs, this one here compiles cleanly, but gives a "double free" runtime error. The reason for this error is that we generate a local temporary for "bar", which is auto-deallocated at the end of the SELECT TYPE block, so that the auto-deallocation of "m%foo" fails. The auto-deallocation of "bar" should not happen, i.e. "bar" should not have the ALLOCATABLE attribute (currently the dump shows "struct .class.t0.a bar"). -- Summary: [OOP] SELECT TYPE with associate-name and allocatable selector 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=44047