Hi all,
attached patch fixes on ICE, when freeing a scalar allocatable component in a
derived typed coarray.
Furthermore does it fix freeing of nested derived typed allocatable
components. A simple code explains the bug that is solved by the patch:
type inner
integer, allocatable :: i
end type
type outer
type(inner), allocatable :: link
end type
type(outer), allocatable :: obj
allocate(obj)
allocate(obj%link)
allocate(obj%link%i)
deallocate(obj%link)
deallocate(obj) ! <- this will generate pseudo-pseudo-code of the kind:
if (obj.link.i != 0) // But link is already NULL, i.e. a crash occurs.
free(obj.link.i)
The patch fixes this by moving the code for freeing link.i into the check if
link is allocated, i.e.:
if (obj.link != 0) {
if (obj.link.i != 0) {
free (obj.link.i);
obj.link.i = 0;
}
free (obj.link);
obj.link = 0;
}
Furthermore does the patch ensure that the handle of an allocatable component
is set to 0.
Bootstraped and regtested ok on x86_64-linux/F23. Ok for trunk?
Regards,
Andre