[J3] [EXTERNAL] Re: Changing address of an allocatable on assignment when shapes match
Vipul Parekh
parekhvs at gmail.com
Sat Aug 24 11:21:09 EDT 2019
On Sat, Aug 24, 2019 at 3:43 AM Van Snyder via J3
<j3 at mailman.j3-fortran.org> wrote:
>
> .. the deallocation before the revised allocation
> causes all associated pointers to become undefined. The reallocation is
> fine and standard conforming, even if the <variable> has the TARGET
> attribute. What's not allowed is using a formerly associated pointer
> after it becomes undefined -- no matter how it became undefined.
>
Under the circumstances then, is the following code conformant with
the standard? I fail to see why it would not be, so any feedback will
be very useful for me.
integer, allocatable, target :: foo(:)
integer, pointer :: bar(:)
foo = [ 1 ]
bar => foo
print *, "bar = ", bar
foo = [ 1, 2 ]
bar => foo
print *, "bar = ", bar
end
Thanks,
Vipul Parekh
More information about the J3
mailing list