[comp.lang.fortran] mixed type assignment in fortran77 corrupts memory elsewhere!

pjd@hpuxa.ircc.ohio-state.edu (Peter J. Dotzauer) (10/22/89)

I am using Fortran77 on a Unix workstation (Tektronix 4330 running BSD
Unix 4.2).

While developing a 6,000 line program, I started getting weird kinds of
errors in different versions of the program that didn't make any sense -
it was soon clear that a few memory locations got corrupted, but how?

After hunting down the problem for more than a week, I found
that the assignment of the type
        iarray(i) = a
(where iarray and i are integers, and a is a real)

was responsible for memory corruption in memory space allocated to some
literals in a different subroutine.


Changing to
        iarray(i) = aint(a)
took care of the problem, but does that make sense? In the original form,
always the correct values, to the nearest integer value of a, got assigned
to intarray(i), but on the side that mixed-type assignment statement did
something very nasty.

Now, what's your opinion out there? Is that a lousy compiler, or am I the
one to blame? After all, I have used such types of assignments for five
years on different f77 compilers without any problems.

Please email to pjd@hpuxa.ircc.ohio-state.edu as I rarely read this newsgoup.
-=-
Peter Dotzauer: Numerical Cartography Lab, Ohio State University, Columbus, OH
         VOICE: (614) 292-1357  FAX: 292-9180  DATA: 293-0081 
        BITNET: ts3285@ohstvma UUCP: ...!osu-cis!hpuxa.ircc.ohio-state.edu!pjd
          FIDO: 1:226/50       ARPA: pjd@hpuxa.ircc.ohio-state.edu [128.146.1.5]