This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [PATCH, Fortran, pr78356, v1] [7 Regression] [OOP] segfault allocating polymorphic variable with polymorphic component with allocatable component
- From: Janus Weil <janus at gcc dot gnu dot org>
- To: Andre Vehreschild <vehre at gmx dot de>
- Cc: GCC-Patches-ML <gcc-patches at gcc dot gnu dot org>, GCC-Fortran-ML <fortran at gcc dot gnu dot org>
- Date: Tue, 15 Nov 2016 22:24:43 +0100
- Subject: Re: [PATCH, Fortran, pr78356, v1] [7 Regression] [OOP] segfault allocating polymorphic variable with polymorphic component with allocatable component
- Authentication-results: sourceware.org; auth=none
- References: <20161115172658.5608e616@vepi2>
Hi Andre,
> attached patch fixes the issue raised. The issue here was, that a copy of the
> base class was generated and its address passed to the _vptr->copy()-method,
> which then accessed memory, that was not present in the copy being an object of
> the base class. The patch fixes this by making sure the temporary handle is a
> pointer to the data to copy.
>
> Sorry, when that is not clear. I am not feeling so well today. So here in
> terms of pseudo code. This code was formerly generated:
>
> struct ac {};
> struct a : struct ac { integer *i; };
>
> a src, dst;
> ac temp;
>
> temp = src; // temp is now only a copy of ac
>
> _vptr.copy(&temp, &dst); // temp does not denote memory having a pointer to i
>
> After the patch, this code is generated:
>
> // types as above
> a src, dst;
> ac *temp; // !!! Now a pointer
>
> temp = &src;
> _vptr.copy(temp, &dst); // temp now points to memory that has a pointer to i
> // and is valid for copying.
>
> Bootstraps and regtests ok on x86_64-linux/F23. Ok for trunk?
ok with me. Thanks for the quick fix!
Cheers,
Janus