This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran, pr59678, v1] -- [F03] Segfault on equalizing variables of a complex derived type


Dear Andre,

The patch is OK with three changes:
(i) Put the PR line in the testsuite ChangeLog;
(ii) Put the dg-do header information in the testcase, together with
lines to say which PR it fixes and who the contributor is; and
(iii) Add the testcase for PR65841 since your patch for pr65792 breaks
this side-effect fix.

I will turn my attention to your patch for pr65792 next and try to
figure out why (iii) is necessary.

Thanks for the patch

Paul



On 18 April 2015 at 12:55, Andre Vehreschild <vehre@gmx.de> wrote:
> 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



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]