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: "Jeffrey J. Potoff" Subject: Re: Mysterious data corruption in Fortran with -automatic Date: 1998/06/04 Message-ID: <35774C1A.2985A59E@rhea.umd.edu>#1/1 X-Deja-AN: 359671478 Content-Transfer-Encoding: 7bit References: <01bd9013$76f09aa0$6f242499@stupidwin95> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: University of Maryland Newsgroups: comp.sys.dec,comp.lang.fortran Kevin G. Rhoads wrote: > > Keith - first, thanks so very much for MOLDY. > > Re data corruption -- I believe the key is later in your > post where you say: > "I should mention that this is compiled with "-g -O2 -automatic" -- the > problem goes away at lower optimization levels." > This really sounds like an optimizer bug. > > "More mysteriously exactly the same behaviour is observed > when the code is compiled with f90 instead of f77" not > mysterious if they are from the same vendor, in which case > they likely share the same back-end, where all the low level > optimizations are performed. > > I have found that on non-trivial code (anything with more than > a few thousand lines), whether it be C or Fortran, that you > are fairly likely to hit some optimizer bug. Numerical computations > tend to be the most likely to trigger optimizer bugs (just my personal > experience, not from any studies). I disagree. Most likely you have hit a 'bug', but it's not the compiler that's the problem, it's the code itself. For well written code you can compile it with *any* flags on *any* platform and it still runs without incident. > > I have made it a rule for some years now to compile EVERYTHING > with optimizations off as well as on and compare the results of > standard test runs. This last year I have been bumping into a new > optimizer bug roughly once every other month. (Of course, I have > been running the code through three different vendor's Fortran > compilers and six different vendor's C compilers.) This is always a good idea. If you don't get the same answers, you know there's a bug in your code. > > If it is an optimizer bug, the only long-term fix is getting > a corrected compiler from the vendor. In the short-term, > since you've found that putting in debugging writes clears > the problem up, may I humbly suggest that opening a NULL > device for output and leaving those WRITEs in, but directed to > NULL, may be a useable work-around Bad idea. Usually this is just masking some bug in your code. (with, of course, suitably > scathing comments about the sloppiness of the compiler vendor's > coders and Q/A testing . . . ;-) ) Uh huh, or more appropriately the sloppiness of the person who wrote the code to begin with. Jeff