On 18.09.22 11:10, Mikael Morin wrote:
Le 18/09/2022 à 08:12, Richard Biener a écrit :
On Sat, Sep 17, 2022 at 9:33 PM Mikael Morin <morin-mik...@orange.fr> wrote:

Le 17/09/2022 à 19:03, Thomas Koenig via Fortran a écrit :

I have a concern about this part, though.  My understanding at the
time was that it is not possible to clobber an individual array
element, but that this clobbers anything off the pointer that this
is based on.

Well, we need the middle-end guys to give a definitive answer on this
topic, but I think it would be a very penalizing limitation if that was
the case.  I have assumed that the clobber spanned the value it was
applied on, neither more nor less, so just the array element in case of
array elements.

There is IL verification that the LHS of a CLOBBER is either
a declaration or a pointer dereference, no array or component
selection is allowed there.  Now, nothing should go wrong here,
but we might eventually just drop those CLOBBERs or ICE if
we frontend hands us an "invalid" one.


Obviously I have assumed too much here; it's probably best to drop this patch.

Probably, yes.

It is unfortunate as there is some desirable behavior within reach here.

I think some of the desired behavior can still be salvaged.  For
example, for

  subroutine foo(a,n)
    integer :: n
    integer, dimension(n), intent(in) :: n

...

  subroutine bar(a)
    integer, intent(out) :: a

...

  integer :: a(3)

  call foo(a,3)
  call foo(a(1),3)

clobbers for the whole array can still be generated, but not for

  call foo(a(2),2)

so one would have to look at the lower bound.

For this case, it would be helpful to clobber a range a(2:), but that
is a wishlist item for the future ;-)

What is unsafe, currently, is

  call bar(a(1))

Best regards

        Thomas

Reply via email to