This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fortran] Improved dependency analysis of pointer variables
- From: Brooks Moses <bmoses at stanford dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: fortran at gcc dot gnu dot org
- Date: Thu, 16 Mar 2006 00:21:38 -0800
- Subject: Re: Fortran] Improved dependency analysis of pointer variables
- References: <44191876.3020902@knmi.nl>
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.
However, the whole point of TARGET is so that optimizations can be made
easily for cases like this, so I think it's quite fair to _assume_ that
Y is not pointed to by any pointer if it doesn't have the TARGET
attribute -- and note that this may cause problems if one violates the
standard by workarounds like the above. (The proper phrase is "cannot
be pointed to by any pointer in standard-conforming code," I suspect.)
- Brooks, going to go change some of my code that violates the standard
this way, because until just now I'd assumed this was legal.