From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,cf4ba3d07912d446 X-Google-Attributes: gid1164f8,public X-Google-Thread: 1094ba,cf4ba3d07912d446 X-Google-Attributes: gid1094ba,public From: Thorsten Ohl Subject: Re: Mysterious data corruption in Fortran with -automatic Date: 1998/06/05 Message-ID: #1/1 X-Deja-AN: 359803685 References: <01bd9013$76f09aa0$6f242499@stupidwin95> <35774C1A.2985A59E@rhea.umd.edu> <01bd9039$7d242ba0$LocalHost@stupidwin95> Organization: TH Darmstadt Newsgroups: comp.sys.dec,comp.lang.fortran "Kevin G. Rhoads" writes: > All of what you've said boils down to >you must be writing buggy > code< asserted with NO justification, based on what was posted NO > reasoning or evidence offered in support Without the original poster supplying complete code (the little snippet that he posted is alread his interpretation of the bug) we can do litte more than guessing. > I fail to see how anyone can reasonable suggest that when code > compiles cleanly, with neither error NOR WARNING and produces two > wildly different results depending ONLY on the compiler settings > that it MUST be bugs in the code, and the compiler is necessarily > faultless. Simple example: most people with prior exposure to C are prone to writing things like if ((x /= 0) .and. (test_condition_assuming_x_not_0 (x))) then .... end if since most compilers don't reorder boolean expressions, this bug will not be noticed until you hit a compiler (like DEC's) that takes advantage of Fortran's fredom to reorder booleans. I have had this (in numerous disguises) more than once. > Are you just flaming? Or do you have some justification you are not > sharing with the rest of us? Careful. Forgetting to SAVE variables is a _very_ common mistake. It still happens occasionally to me and the response to the -automatic switch is a smoking gun when a student shows up with this problem [believe me: almost all do at one point in their career ...] True anecdote: A few months back I tested a new fortran compiler on some old code that worked on IBMs with VM and MVS, on VAXen with VMS, and on more flavors of UNIX that I can remember. Everywhere the results where (up to floating point differences) identical. The new compiler appeared to produce complete garbage and I was ready to blame the compiler. Then I tried the -static switch (the opposite of -automatic on this compiler) and the code produced correct results. Then it took very little time to track down a forgotten SAVE. -- Thorsten Ohl, Physics Department, TU Darmstadt -- ohl@hep.tu-darmstadt.de http://crunch.ikp.physik.tu-darmstadt.de/~ohl/ [<=== PGP public key here]