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: Robert O'Dowd Subject: Re: Mysterious data corruption in Fortran with -automatic Date: 1998/06/05 Message-ID: <3577C0BE.3F3C879D@nonexistant.com>#1/1 X-Deja-AN: 359776835 Content-Transfer-Encoding: 7bit References: <01bd9013$76f09aa0$6f242499@stupidwin95> <35774C1A.2985A59E@rhea.umd.edu> <01bd9036$7ae7fea0$LocalHost@stupidwin95> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Defence Science & Technology Organisation Newsgroups: comp.sys.dec,comp.lang.fortran Kevin G. Rhoads wrote: > > Please read what I wrote and respond to that. > > If the code gives CORRECT answers with compiler > optimizations OFF and it gives WRONG answers > with compiler optimizations ON -- question, where > is the bug? > > Answer, in the compiler optimizations -- the code > did NOT change, the compiler did. Ah, if the world was exactly that simple. There are many things in language specs that are "undefined". This means the compiler is free to to as it will on code that invokes undefined behaviour. A good optimiser will push the letter of the law with the language, if by doing so it can improve performance (however you measure "performance"). In doing so, it could well change the results you get from the non-compliant code. Both results are consistent with the word "undefined behaviour". - Robert O'Dowd Ph +61 (8) 9553 3618 DSTO Bldg A51 Fax +61 (8) 9553 3577 HMAS Stirling Email: robert.odowd@dsto.defence.gov.au Rockingham, Western Australia, 6958 Disclaimer: Opinions above are mine and may be worth what you paid for them