On 11/02/2009 01:30 PM, Dominique Dhumieres wrote:
With the code in http://gcc.gnu.org/ml/fortran/2009-11/msg00011.html
gfortran 4.2.4 gives
EQUIVALENCE (CSTORE(1),XSTORE,ISTORE)
1
Error: Initialized objects 'cstore' and 'istore' cannot both be in the EQUIVALENCE statement at (1)
which is much better than what I get with gfortran 4.3.4, 4.4.2, and trunk:
Error: Overlapping unequal initializers in EQUIVALENCE at (1)
It might be more enlightening, but the error message of 4.1/4.2 is
misleading/wrong: cstore and istore may be both initialized - as long as
the initializer affects different bytes.
For instance, in the following program both i and j are (partially)
initialized. In this case the program is valid,* compiles and prints the
expected values. (gfortran 4.1/4.2 reject it.)
However, if all of "j" is initialized, there is an overlap and thus the
program is invalid:
integer :: i(2)
integer :: j(2)
data i(1)/5/
data j(2)/7/
!data j/1,1/
equivalence (i,j)
print *, i
print *, j
end
Tobias
(* Well, kind of. If one initializes "i(1)", strictly speaking accessing
"j(1)" is invalid as "j(1)" is not initialized; but I think many
utilizations of EQUIVALENCE rely on it. Otherwise, EQUIVALENCE would
just save memory and could not be used as TRANSFER replacement.
[TRANSFER is also ill defined, but is standard conform.])