This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: equivalence croakage


Tobias Burnus wrote:
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.])


Tobias, Jerry, Steve, Dominique, Tim,


Thx y'all for your friendly and encouraging advice.

I managed to fix all compile and link errors. Some initial tests even confirm that the binaries work!

Point is that I do NOT intend to make the gobs of old fortran
standard-compliant (just want it to compile and work on platforms I care
about), nor do I plan to write more new fortran code than absolutely
necessary.

greets,
H.


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