Fortran编程BUG的都市传说

来源:百度文库 编辑:神马文学网 时间:2024/04/28 03:54:11
source: http://www-users.cs.york.ac.uk/susan/cyc/p/fbug.htm
Fortran bug Urban Legend
In an earlier version of my Fortran language entry, I repeated the "well-known" Fortran bug that lost a spacecraft:
If a variable is not declared, it is implicitly given a type based on its first letter (I to N being integers, the rest floats). This led to the famous case of losing a spacecraft, when DO I = 1.100 was used instead of DO I = 1,100. The former statement assigns 1.100 to the variable DOI (spaces being ignored in names!), the latter is the start of a DO-loop.
However, on 25 February 1999, I received the following email from Brian Blank, which indicates that this well-known 'fact' is just an Urban Legend after all (which shows that I am just as guilty of repeating ULs as anyone):
Ordinarily I don't attempt to correct the web one fact at a time but a few days ago I received an email from a Belgian Scot who discovered one of my publicly accessible private pages via Alta Vista's infernal spider. It turns out that one of my computer factoids, the veracity of which I had confirmed in the Encyclopedia Britannica and the New York Public Library Science Desk Reference, was wrong. I learned some interesting things in verifying my correspondent's claim and feel quite content that I am no longer propagating a myth.
So either I am passing on a favor or seeking an outlet for revenge. The line of FORTRAN code
DO 10 I = 1.100apparently did indeed occur. The compiler apparently did what it was supposed to do, ignoring white space and implicitly declaring and then assigning DO10I. Remarkably, the program was actually tested before use. The error was detected, thereby saving a rocket but ruining a future factoid. The demise of the rocket has been widely reported and has become part of programmer folklore.
Reference: Fortran Story - The Real Scoop, Forum on Risks to the Public in Computer and Related Systems, Vol. 9 #54, ACM Committee on Computers and Public Policy, 1989.
Regards
Brian Blank
Department of Mathematics
Washington University in St. Louis
St. Louis, MO 63130
email: brian@math.wustl.edu
http://ascc.artsci.wustl.edu/~bblank/