This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: Revamp fortran array types
Tobias Burnus wrote:
On 08/19/2009 03:01 PM, Michael Matz wrote:
On Wed, 19 Aug 2009, Toon Moene wrote:
Two names must not refer to the same or overlapping storage unless you,
the programmer, indicate that they do (by either using EQUIVALENCE or
designating the storage with the TARGET attribute).
I agree about TARGET, but I do not fully agree about EQUIVALENCE.
Equivalenced variables share the same memory location, but only under
certain restrictions on may make use of it. (Though the expectations of
the users is probably more than what the standard guarantees.)
Ah, sorry. The alias rules I tried to condense into a single sentence
are about what you, the programmer can/not do *in case of writes*.
The following code is perfectly OK:
DIMENSION A(10)
A = 10.0
CALL SUB(A,A)
END
SUBROUTINE SUB(A,B)
REAL, INTENT(IN) :: A(:), B(:)
...
END
Likewise, the following is OK, although its *meaning* is not specified
by the Standard (i.e., the value of X is undefined):
EQUIVALENCE(I,X)
X = 10.0
I = 10
PRINT*,X
END
There's no doubt, however, that setting I destroys the previous value of
X (and that's the only interesting property of this code from the point
of alias analysis, which, e.g., can't change the order of the assignment
to X and I).
--
Toon Moene - e-mail: toon@moene.org - phone: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
At home: http://moene.org/~toon/
Progress of GNU Fortran: http://gcc.gnu.org/gcc-4.5/changes.html