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

Andre Vehreschild vehre@gmx.de
Tue Nov 15 16:27:00 GMT 2016


Hi all,

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?

Regards,
	Andre
-- 
Andre Vehreschild * Email: vehre ad gmx dot de 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr78356_v1.clog
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20161115/65308fad/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr78356_v1.patch
Type: text/x-patch
Size: 4332 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20161115/65308fad/attachment.bin>


More information about the Fortran mailing list