From: rubber@bounce.com (Keith Refson - real email address in signature)
Subject: Re: Mysterious data corruption in Fortran with -automatic
Date: 1998/06/05 [thread overview]
Message-ID: <wxra14fd7u.fsf@earth.ox.ac.uk> (raw)
In-Reply-To: 01bd9036$7ae7fea0$LocalHost@stupidwin95
"Kevin G. Rhoads" <T_Rhoads@NoSpam.CLASSIC.MSN.COM> writes:
> If the code gives CORRECT answers with compiler optimizations OFF
> and it gives WRONG answers with compiler optimizations ON --
> question, where is the bug?
I know this seems like an obvious conclusion but I am afraid in my
(many years of) experience it is false. One obvious way this might
happen is if you omitted to initialize a variable. Compiling with no
optimization will often result in it being initialized to zero -- even
though you didn't ask for it in your code. However the optimized code
will pick up whatever value was last in some register or memory
location and will therefore give different results. Another mistake
is to pass the same actual argument twice to two different dummy
arguments in a subroutine. The standard entitles the compiler to
assume that these refer to distinct areas of store and optimizing on
that assumption may not produce the results you intended. Yet another
faulty but common assumption is that variables retain their values
between invocations of a subprogram.
> Answer, in the compiler optimizations -- the code did NOT change,
> the compiler did.
But incorrect code with "undefined" behaviour may yet produce
"correct" results. Perhaps the language lawyers don't make this point
sufficiently clear.....
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.
Keith refson
--
------------------------------------------------------------------------------
Email: Keith.Refson@ | Tel: +44 1865 272026 | Dr Keith Refson, |
earth.ox.ac.uk | Fax: +44 1865 272072 | Dept of Earth Sciences |
| Parks Road, Oxford OX1 3PR, UK|
------------------------------------------------------------------------------
next prev parent reply other threads:[~1998-06-05 4:00 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-06-04 4:00 Mysterious data corruption in Fortran with -automatic Keith Refson - real email address in signature
1998-06-04 4:00 ` Kevin G. Rhoads
1998-06-04 4:00 ` Jeffrey J. Potoff
1998-06-04 4:00 ` Kevin G. Rhoads
1998-06-05 4:00 ` Thorsten Ohl
1998-06-05 4:00 ` Kevin G. Rhoads
1998-06-05 4:00 ` William Clodius
1998-06-05 4:00 ` William Clodius
1998-06-05 4:00 ` Ian Chivers
1998-06-05 4:00 ` Kevin G. Rhoads
1998-06-05 4:00 ` Ian Pattie
1998-06-05 4:00 ` Jeffrey J. Potoff
1998-06-05 4:00 ` Kevin G. Rhoads
1998-06-06 4:00 ` Rob Komar
1998-06-04 4:00 ` Kevin G. Rhoads
1998-06-05 4:00 ` Catherine Rees Lay
1998-06-04 4:00 ` Kevin G. Rhoads
1998-06-05 4:00 ` Harald Anlauf
1998-06-05 4:00 ` Kevin G. Rhoads
1998-06-05 4:00 ` Robert O'Dowd
1998-06-05 4:00 ` Kevin G. Rhoads
1998-06-05 4:00 ` Stuart Brook
1998-06-05 4:00 ` Jeffrey J. Potoff
1998-06-05 4:00 ` Keith Refson - real email address in signature [this message]
1998-06-05 4:00 ` Kevin G. Rhoads
1998-06-05 4:00 ` Robert O'Dowd
1998-06-05 4:00 ` John Appleyard
1998-06-05 4:00 ` Keith Refson - real email address in signature
1998-06-05 4:00 ` Kevin G. Rhoads
1998-06-05 4:00 ` Jeffrey J. Potoff
1998-06-08 4:00 ` Paul Winalski
1998-06-04 4:00 ` Stuart Brook
1998-06-04 4:00 ` Kevin G. Rhoads
1998-06-05 4:00 ` Stuart Brook
1998-06-05 4:00 ` Toon Moene
1998-06-04 4:00 ` Thorsten Ohl
1998-06-06 4:00 ` SUMMARY: Code errors which can masquerade as compiler bugs " Kevin G. Rhoads
1998-06-11 4:00 ` Ron Sverdlove x2517
1998-06-08 4:00 ` Steve Lionel
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox