[Patch, fortran, pr59678, v1] -- [F03] Segfault on equalizing variables of a complex derived type
Andre Vehreschild
vehre@gmx.de
Sat Apr 18 10:55:00 GMT 2015
Hi all,
this patch fixes a deep copy issue, when allocatable components of an entity
were not allocated. Before the patch the deep copy was run without
checking if the component is actually allocated and the program crashed because
a null pointer was dereferenced. Furthermore, was the code to copy a structure
component not checking the correct ref to determine whether a component was
allocated, when allocatable components were nested. Example:
type InnerT
integer, allocatable :: inner_I
end type
type T
type(InnerT), allocatable :: in
end type
The pseudo pseudo code generated for this was something like:
subroutine copy(src,dst)
dst = src
if (allocated (src.in.inner_I)) // crash
allocate (dst.in)
end if
dst.in.inner_I = src.in.inner_I // crash
end subroutine
The patch fixes this by generating:
subroutine copy(src,dst)
dst = src
if (allocated (src.in))
allocate (dst.in)
dst.in= src.in
if (allocated (src.in.inner_I))
allocate (dst.in.inner_I)
dst.in.inner_I = src.in.inner_I
end
end
end subroutine
Of course is this pseudo pseudo code shortened dramatically to show just the
necessary bits.
Bootstraps and regtests ok on x86_64-linux-gnu/F21.
Ok, for trunk?
Thanks to Dominique for identifying the pr addressed by this patch.
Regards,
Andre
--
Andre Vehreschild * Email: vehre ad gmx dot de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr59678_1.clog
Type: application/octet-stream
Size: 835 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20150418/e36993d3/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr59678_1.patch
Type: text/x-patch
Size: 18702 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20150418/e36993d3/attachment.bin>
More information about the Fortran
mailing list