Compiling (with ifort 13.1.1) and executing the following code
type :: t
end type t
type :: t1
class(t), pointer :: tp
procedure :: set
procedure :: unset
end type t1
function t_new() result(r)
type(t), pointer :: r
end function t_new
subroutine set(a, tp)
class(t1) :: a
class(t), target :: tp
a%tp => tp
end subroutine set
class(t1) :: a
print *, "Dealocating"
print *, "Deallocated"
end subroutine unset
end module tt
type(t1) :: a
end program test
forrtl: severe (173): A pointer passed to DEALLOCATE points to an object that cannot be deallocated
Image PC Routine Line Source
pointer 000000000046D7AE Unknown Unknown Unknown
pointer 000000000046C246 Unknown Unknown Unknown
pointer 0000000000424FC2 Unknown Unknown Unknown
pointer 00000000004068BB Unknown Unknown Unknown
pointer 00000000004050E6 Unknown Unknown Unknown
pointer 0000000000402C57 Unknown Unknown Unknown
pointer 0000000000402B3C Unknown Unknown Unknown
libc.so.6 00007FB324690A15 Unknown Unknown Unknown
pointer 0000000000402A39 Unknown Unknown Unknown
but using gfortran yields
Is this a bug?
OOPS, I wrote the following before seeing the above post.
Ignore the following (as you are using TBP)
>> I'm having a similar difficulty of deallocating pointers to unlimited polymorphic components of a derived type.
The above states that you have an external (to the derived type) pointer to an allocatable within the derived type.
Should this component be ALLOCATABLE, it would also have to have the TARGET attribute .AND. the (external) pointer could not deallocate this component.
Should this component be POINTER (which is/was allocated), then the external pointer could perform the deallocate **** with your requirement to NULLIFY the component pointer, and all other pointers that may be pointing to that component.
You would be best served by creating a type bound function/subroutine to perform this.