[PATCH, Fortran, pr78356, v1] [7 Regression] [OOP] segfault allocating polymorphic variable with polymorphic component with allocatable component

Andre Vehreschild vehre@gmx.de
Wed Nov 16 13:46:00 GMT 2016


Hi Janus,

thanks for the quick review. Committed as r242490.

Regards,
	Andre

On Tue, 15 Nov 2016 22:24:43 +0100
Janus Weil <janus@gcc.gnu.org> wrote:

> 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


-- 
Andre Vehreschild * Email: vehre ad gmx dot de 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: submit.diff
Type: text/x-patch
Size: 5058 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20161116/fc888cca/attachment.bin>


More information about the Fortran mailing list