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

Mikael Morin morin-mikael@orange.fr
Mon Sep 19 20:50:10 GMT 2022


Le 19/09/2022 à 21:46, Harald Anlauf a écrit :
> Am 18.09.22 um 22:55 schrieb Mikael Morin:
>> Le 18/09/2022 à 20:32, Harald Anlauf a écrit :
>>>
>>> Assumed shape will be on the easy side,
>>> while assumed size likely needs to be excluded for clobbering.
>>>
>> Isn’t it the converse that is true?
>> Assumed shape can be non-contiguous so have to be excluded, but assumed
>> size are contiguous, so valid candidates for clobbering. No?
> 
> I really was referring here to *dummies*, as in the following example:
> 
> program p
>    integer :: a(4)
>    a = 1
>    call sub (a(1), 2)
>    print *, a
> contains
>    subroutine sub (b, k)
>      integer, intent(in)  :: k
>      integer, intent(out) :: b(*)
> !   integer, intent(out) :: b(k)
>      if (k > 2) b(k) = k
>    end subroutine sub
> end program p
> 
> 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.


More information about the Fortran mailing list