[PATCH 09/10] fortran: Support clobbering of variable subreferences [PR88364]

Mikael Morin morin-mikael@orange.fr
Tue Sep 20 08:46:41 GMT 2022


Le 20/09/2022 à 08:54, Thomas Koenig a écrit :
> 
> On 19.09.22 22:50, Mikael Morin wrote:
>> Le 19/09/2022 à 21:46, Harald Anlauf a écrit :
>>>
>>> Assumed size (*) is just a contiguous hunk of memory of possibly
>>> unknown size, which can be zero.  So you couldn't set a clobber
>>> for the a(1) actual argument.
>>>
>> Couldn't you clobber A entirely?  If no element of B is initialized in 
>> SUB, well, A has undefined values on return from SUB.  That's how 
>> INTENT(OUT) works.
> 
> Yes, I think so - you are passing the starting element of an array
> to an assumed-size array via storage association rules.
> 
> It has to be an explicit interface, of course, otherwise it is
> unclear if an array or an array element is passed.
> 

I have looked for the relevant excerpts from the standard.
 From 15.5.2.11 (sequence association):

> If the dummy argument is not of type character
> with default or C character kind, and the actual argument is an array element designator, the element sequence
> consists of that array element and each element that follows it in array element order.

> If the dummy argument is
> assumed-size, the number of elements in the dummy argument is exactly the number of elements in the element
> sequence.

So the dummy size, even if not known to the programmer, is clearly 
defined (to the full array size in your example).


More information about the Fortran mailing list