This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Fortran] Improved dependency analysis of pointer variables


> Consider instead this slightly modified version:
>
> ! { dg-do compile }
> ! { dg-options "-O2 -fdump-tree-original" }
>    integer :: i(5)
>    real(4) :: x(5)
>    equivalence(x,i)
>
>    i = (/ 1, 0, 3, 5, 0 /)
>    where (i(1:4) .ne. 0)
>      x(2:5) = -42.
>    end where
>    end
> ! { dg-final { scan-tree-dump-times "malloc" 1 "original" } }
> ! { dg-final { cleanup-tree-dump "original" } }
>
> which is miscompiled both on mainline and with my patch.  It appears
> that the gfc_are_equivalenced_arrays test isn't doing its job in this
> case?  Perhaps gfc_are_equivalenced_arrays *is* doing its job and my
> modified example is considered invalid Fortran.

Technically it's illegal code, but we want to support it for the same reason 
we support aliasing in C unions.

Note that equivalenced variables may not have the target attribute, so pointer 
variables may not point to them. This means objects of different types can 
only alias when they have been explicitly names in an equivalence block.

gfortran currently doesn't reject TARGET variables in common blocks. That's 
probably a bug.

Paul


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]