Ping [PATCH, Fortran, v1] Fix deallocation of nested derived typed components
Andre Vehreschild
vehre@gmx.de
Fri Dec 9 12:33:00 GMT 2016
Hi Jerry,
thanks for the review. Committed as r243480.
Regards,
Andre
On Thu, 8 Dec 2016 12:10:55 -0800
Jerry DeLisle <jvdelisle@charter.net> wrote:
> On 12/08/2016 05:42 AM, Andre Vehreschild wrote:
> > Ping!
> >
> > On Fri, 2 Dec 2016 13:28:40 +0100
> > Andre Vehreschild <vehre@gmx.de> wrote:
> >
> >> 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
> >
> >
>
> I think OK.
>
> Jerry
--
Andre Vehreschild * Email: vehre ad gmx dot de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: submit.diff
Type: text/x-patch
Size: 35752 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20161209/41e3f452/attachment.bin>
More information about the Fortran
mailing list