[J3] 15.5.2.5 Allocatable and pointer dummy variables

José Rui Faustino de Sousa jrfsousa at gmail.com
Wed Sep 2 09:12:32 EDT 2020


On 02/09/20 00:42, Malcolm Cohen wrote:
 >

First of all thank you very much for your kind and detailed answer.

> The Editor remarks: You can’t just stick a requirement in the middle of 
> a condition – it is not grammatical and so does not make sense.
> 

It was not my intention to rewrite the standard or propose any new 
functionality. I was just trying to make it more clear what my question was.

What I am trying to ask is: from the point of view of someone enforcing 
the standard rules what is the intended interpretation of the wording of 
the standard?

> (1) If one wants to have different requirements for POINTER/ALLOCATABLE 
> actual arguments corresponding to INTENT(IN) POINTER/ALLOCATABLE 
> dummies, those requirements need to be explicitly spelled out.
> 

Yes, this is my point exactly.

The statement on the response to F08/0059 that "the imposition of these 
requirements to the auto-targetting feature was an oversight" seems to 
create an "asymmetry" between what is allowed for pointers and what is 
allowed for allocatables.

> (3) You remark that your “new wording” would make “call sp1(x)” valid. I 
> remark that x is neither allocatable nor a pointer, so this subclause 
> (which only applies to allocatable and pointer actual arguments) is not 
> relevant in the first place.
> 

I meant the new wording that came from the response to F08/0073 and 
F08/0059.

I would not call what I wrote a "new wording"... :-)

> (4) You claim “But it still seems to forbid code like this”, followed by 
> three examples, the first of which is undeniably invalid,
 >

This is the main point of my (mis)understanding of 15.5.2.5.

My understanding of auto-targetting, which seems to follow the same line 
of reasoning of F08/0059, is:

If you have:

(some type, kind, rank), pointer :: p

subroutine sub(q)
(declared type the same as p), pointer, intent(in) :: q
...

And it is legal to do:

p => x

Then:

call sub(x)

must also be legal.

Which AFAICT just boils down to the argument to the dummy pointer must 
respect the usual assignment rules and the dummy must have the intent 
(in) attribute.

So, if has stated in the response to F08/0059, the restrictions placed 
by 15.5.2.5 cannot interfere with the auto-targetting feature all the 
examples I provided must be legal.

And, like you said in (1), if it applies to pointers then it should also 
apply to allocatables.

Even more so if the objective of 15.5.2.5 is to avoid situations like 
those stated in note 1, just having the intent (in) attribute seems to 
do the trick.

> but the 
> remaining two do not have an actual argument with the same attribute as 
> the dummy argument, so again, this subclause is not relevant to those 
> examples.
> 

So 15.5.2.5 only applies when there is no mixing.

> (6) Your examples with polymorphic allocatable intent(in) can be handled 
> with polymorphic non-allocatable intent(in) optional, so there would be 
> virtually no gain in functionality here.
> 

My question is merely formal, although it could be useful to write 
checking or debugging procedures.

Thank you very much for your time.

Best regards,
José Rui



More information about the J3 mailing list