Fortran] Improved dependency analysis of pointer variables

Paul Brook paul@codesourcery.com
Thu Mar 16 15:07:00 GMT 2006


On Thursday 16 March 2006 08:21, Brooks Moses wrote:
> Toon Moene wrote:
> >  > Of course, looking closer there
> >  > couldn't possibly be a dependency using type-based aliasing, as Grid
> >  > points to an array of integers and Y points to an array of reals.
> >
> > But a far better argument would be that Y isn't a TARGET, and therefore
> > cannot be pointed to by *any* pointer.
>
> Is that necessarily true?
>
> For instance, the following code will associate a pointer with a
> variable that isn't a TARGET:
>
> subroutine assoc(a,b)
>    integer, pointer :: a
>    integer, target :: b
>    a => b
> end subroutine
> program notarget
>    integer, pointer :: a
>    integer :: b
>    call assoc(a, b)
> end program
>
> This is a standard violation, I believe, as the standard says that
> objects without the TARGET attribute "shall not be associated with any
> accessible pointer".  However, I don't think this can reliably be tested
> for in all cases.

We aren't required to reject all illegal code. It's always possible to 
circumvent static compiler checks if you try hard enough. In the case above A 
is not valid after assoc returns.

FWIW I previously assumed that pointer variables could point to allocatable 
variables, even when they don't have TARGET attribute. It appears that is 
wrong, so the existing dependency code is probably overly conservative.

Paul



More information about the Gcc-patches mailing list