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: John Appleyard Subject: Re: Mysterious data corruption in Fortran with -automatic Date: 1998/06/05 Message-ID: <3pq$jBA3B$d1QAJU@POLYHDRN.demon.co.uk>#1/1 X-Deja-AN: 359827005 X-NNTP-Posting-Host: polyhdrn.demon.co.uk:158.152.76.50 References: <01bd9013$76f09aa0$6f242499@stupidwin95> <35774C1A.2985A59E@rhea.umd.edu> <01bd9036$7ae7fea0$LocalHost@stupidwin95> <3577C554.9F50B096@nonexistant.com> X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 897055137 nnrp-04:21404 NO-IDENT polyhdrn.demon.co.uk:158.152.76.50 Organization: Polyhedron Software Ltd MIME-Version: 1.0 Newsgroups: comp.sys.dec,comp.lang.fortran In article <3577C554.9F50B096@nonexistant.com>, Robert O'Dowd writes >Keith Refson - real email address in signature wrote: >>[Snip] >> Nevertheless I believe the part of code that I am having trouble with >> and started this thread about does *not* suffer from failure to >> initialize, aliasing or assumptions of SAVE behaviour or array bounds >> errors (at least not in the part where the faulty result occurs). Does >> anyone have any further suggestions as to what to look for? If not >> then maybe this really is one of the relatively rare cases of a >> genuine optimizer bug. >> > >Failure to initialise, aliasing, assumptions about SAVE, and array >bounds >errors anywhere in your complete program can cause faulty results. > >Somewhere in this thread, I recall a mention that insertion of a >write() statement made the program produce correct results. > >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. > I totally agree about the dangers of uninitialised variables, array bound errors and the like, and particularly about the incorrectness of assuming that if it works with compiler A, but not with compiler B, then compiler B is bugged - but... ... this one looks like a compiler bug to me. I'd be happier if I knew the value if POSTMP(1) and POSION before the assignment to NGRPX, but subject to that, and taking into account the checks the author has made, it's difficult to explain any other way. I suppose NGRPX/Y/Z might be aliased, or the optimiser might have reordered code so that something with an aliasing implication was executed after the 1101 loop and before you inspected POSTMP, but that's a long shot. I have found bugs just like this, even down to the WRITE making it go away. The act of printing forces the optimiser to regularise things, so values get put back where they belong. One trick I used successfully (on a completely different platform) was to pass the offending variable to a subroutine which prints it, rather than printing directly. However you've already got the evidence using the debugger. What does the compiler vendor say? -- John Appleyard John@polyhedron.com John@polyhedron.co.uk Polyhedron Software Ltd. Programs for Programmers - QA, Compilers, Graphics ************ Visit our Web site on http://www.polyhedron.co.uk/ ************