https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118120

--- Comment #11 from anlauf at gcc dot gnu.org ---
(In reply to kargls from comment #10)
>> > It is completely irrelevant that "result" is a dummy.  Just try it.
> > And creating a temporary for *every lhs pointer* cannot be acceptable.
> > There must be something more "lightweight".
> 
> I agree it's not the best solution.  This is why I called it
> a 'big hammer'.  Checking for a dummy argument is simply 
> trying to reduce the biggest of the hammer.  I suspect the
> aliasing issue is more likely to occur through argument 
> association, but users can be creative.  Feel free to 
> pursue your patch with an expanded comment.

Looks like you are assuming innocuous users falling into the aliasing trap...
This is the variation is was testing too:

program main
  implicit none
  integer :: k
  complex, target :: data(21)
  do k=1,21
     data(k) = cmplx(-k,0.0)
  end do
  call test(1, 1, data)
  print *, data
contains
  subroutine test(i, j, data)
    integer :: i, j
    complex, target  :: data(21)
    real, pointer    :: result(:,:,:,:)
    complex, pointer :: temp(:,:)
    result(i:i,j:j,1:4,1:5) => data(2:)%re
    temp(1:4,1:5)           => data(1:20)
    result(i,j,:,:) = abs(temp)
  end subroutine test
end program main

Look, no pointer dummy involved. :-)

I can polish my patch and submit to see whether I get slapped or not.

Reply via email to