From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1094ba,cf4ba3d07912d446 X-Google-Attributes: gid1094ba,public X-Google-Thread: 1164f8,cf4ba3d07912d446 X-Google-Attributes: gid1164f8,public From: "Kevin G. Rhoads" Subject: Re: Mysterious data corruption in Fortran with -automatic Date: 1998/06/05 Message-ID: <01bd908c$0be7be40$LocalHost@stupidwin95>#1/1 X-Deja-AN: 359842769 References: <01bd9013$76f09aa0$6f242499@stupidwin95><35774C1A.2985A59E@rhea.umd.edu><01bd9036$7ae7fea0$LocalHost@stupidwin95> <3577C554.9F50B096@nonexistant.com> Newsgroups: comp.sys.dec,comp.lang.fortran >This is actually a danger sign; it is a clear sign that some >part of memory is being incorrectly written to. Inserting the >write statement simply changes the place that gets written to, >but doesn't do away with the bad behaviour. Well it can do that, BUT inserting a write can also-- -change the use-tagging for variables referenced -can cause additional components of the run-time library to be linked in -can shift a variable from automatically register allocated into storage ('cause it has to be passed to . . . in the RTL) -can trigger shifts of code from local to distant (N.B. - this is NOT just an x86 perversion, the 68k family (for example) has 16 bit offset instructions that are often used to save 2 bytes of address and the corresponding bus-traffic delays --so that many 68k targetting compilers had 64k limits on code in a "single" chunk, and any 32 bit machine which offers 16 bit "local" addressing modes can have this issue) And, in fact, for -compilers which arrange storage so that data is before code, -or use Harvard architecture (separate code and data address spaces) -or use segmented addressing, inserting a write may well NOT change where the variables are addressed or located. YES - Uninitialized variables can lead to all sorts of intermittent errors. That's why many compilers have tests for this and while such automatic testing is not perfect, it is something one should habitually require one's code to pass. Similarly, all variables should be declared - which Fortran standards do not require, but many compilers offer the option to enforce. And depending upon the persistence of an unSAVEd variable is (in essence) another variant of the uninitialized variable. But putting in a global SAVE (no variables specified) and trying that variant periodically will help uncover this bug. -- Kevin G. Rhoads, Ph.D. T_Rhoads@NO_SPAM.Classic.MSN.COM KRhoads@NO_SPAM.CmpNetMail.com