[J3] surprisingly PURE
Vipul Parekh
parekhvs at gmail.com
Mon Apr 20 21:18:36 EDT 2020
On Mon, Apr 20, 2020 at 1:35 AM Malcolm Cohen via J3 <
j3 at mailman.j3-fortran.org> wrote:
> ..
>
> Perhaps the most obvious fix is to disallow a local variable in a PURE
> subprogram from having a data pointer component that is default-initialised
> to a target that is not a local variable of the subprogram. That might be
> too big a hammer ..
>
>
>
> C1589a A nonallocatable nonpointer local variable of a pure subprogram, or
> of a BLOCK construct within a pure subprogram, shall not have a
> default-initialized ultimate component that is a data pointer component, if
> the data pointer component has an initial-data-target that is not a local
> variable of the subprogram.
>
>
>
> I note there is possibly another example, using allocation. ..
>
>
>
> One could prohibit this second example by changing “ultimate component” in
> C1589a to “component at any level of component selection”. However, that
> does looks like a hammer that is too big, and so since it is the allocation
> that is doing the bad thing, perhaps we should consider a constraint on the
> allocation instead. (Wordsmithing such a constraint left as an exercise to
> the reader.)* ..*
>
Hi Bob, Malcolm, and everyone,
Since the context is PURE procedures which is of rather high importance in
modern programming, especially parallel computing, will not proceeding with
the biggest hammer one can come up with be the better approach?
What would be the issue with something like the following as C1589a? Note
constraint C1594 already imposes quite a few heavy demands on processors,
so I would like to think something like this will not be any further
onerous on compilers than the standard as-is. So it will be good to read
the feedback from those working on processor implementations.
C1589a A local variable of a pure subprogram, or of a BLOCK construct
within a pure subprogram, shall not be used in a variable-definition
context (19.6.7) if the variable is a derived type where the type has a
default-initialized ultimate component at any level of component selection
that is a data pointer component and such a data pointer component has an
initial-data-target that is not a local variable of the subprogram.
Regards,
Vipul Parekh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20200420/edcd73a4/attachment.htm>
More information about the J3
mailing list