Hi Andre,

Thanks for submitting this patch .  What can a program do with the object after 
it has been allocated?  Below is a simplified version of the code submitted in 
pr65795 and the compile-time error that results from attempting accessing the 
co-indexed component of the allocated object.  Does the patch address this 
error?

Damian

$ cat bug65795.f90 
implicit none

type t2
  integer, allocatable :: x
end type t2

type t3
  type(t2), allocatable :: caf[:]
end type t3

type(t3) :: c

allocate(c%caf[*])
c%caf%x = this_image()
c%caf = c%caf[1]
end

$ caf bug65795.f90 
bug65795.f90:15:8:

 c%caf = c%caf[1]
        1
Error: Sorry, coindexed coarray at (1) with allocatable component is not yet 
supported

$ gfortran --version
GNU Fortran (MacPorts gcc6 6-20160306_0) 6.0.0 20160306 (experimental)




> On Apr 3, 2016, at 6:35 AM, Andre Vehreschild <ve...@gmx.de> wrote:
> 
> Hi all,
> 
> attached patch fixes a segfault when allocating a coarray of a type
> that has allocatable components. Before the patch the compiler tried
> to ref the component to nullify from the coarray's base address and not
> from its .data component. The proposed patch fixes this by preventing
> the nullify of the components in the array_allocate() for coarrays,
> because the components are nullified again afterwards by copying a
> fully nullified copy of the type to the coarray's data component.
> 
> There albeit is an alternative to this patch:
> 
> trans-array.c: 5556+
> 
> -       tmp = gfc_nullify_alloc_comp (expr->ts.u.derived, se->expr,
> +       tmp = gfc_nullify_alloc_comp (expr->ts.u.derived, coarray ?
> +                                             pointer : se->expr, 
>                                     ref->u.ar.as->rank);
> 
> The above adds a second nullify to the generated code before the one
> done the object copy mentioned above. 
> 
> Because I am unsure which patch is best, I propose both. I do favor of
> course the one without the duplicate nullify as attached.
> 
> Bootstrapped and regtested ok on x86_64-linux-gnu/F23. Ok for trunk?
> 
> The patch also applies (with a small delta) to gcc-5 w/o any
> regressions. Ok for gcc-5-branch?
> 
> Regards,
>       Andre
> -- 
> Andre Vehreschild * Email: vehre ad gmx dot de 
> <pr65795_1.clog><pr65795_1.patch>

________________________________
Damian Rouson, Ph.D., P.E.
President, Sourcery Institute
http://www.sourceryinstitute.org
+1-510-600-2992 (mobile)

Reply via email to