From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 110292,45b50f14dadfce5b X-Google-Attributes: gid110292,public X-Google-Thread: 1164f8,45b50f14dadfce5b X-Google-Attributes: gid1164f8,public X-Google-Thread: 102b75,45b50f14dadfce5b X-Google-Attributes: gid102b75,public From: qed@chromatic.com (Paul Hsieh) Subject: Re: Final kick at the "Merced Guessing Game" Date: 1997/10/15 Message-ID: #1/1 X-Deja-AN: 281127688 References: <61g30t$o2n@news-rocq.inria.fr> <343C34A7.B715A348@tonys.ecology.umn.edu> <3440F805.C98BB347@tonys.ecology.umn.edu> <61tfaa$9fr@sis.cambridge.arm.com> <61uoiu$19e$1@goanna.cs.rmit.edu.au> Organization: Chromatic Research Inc. Newsgroups: comp.sys.intel,comp.arch,comp.sys.dec On 14 Oct 1997 13:23:10 +1000, Richard A. O'Keefe said: > Paul Rubin writes: > >> BOOL = F() .AND. (G() .OR. H()) > > >Is this C statement equivalent to the Fortran? > >My Fortran is very rusty.... :-) > > > bool = !(!f() | (!g() & !h())); > > In a word, NO. The C version absolutely requires all of the function > calls to be performed. In the above expression that is true. However if the expression was written as: bool = !(!f() || (!g() && !h())); Of course, this has a different behavior which includes potentially not calling some of these expressions. > [...] A C compiler is not allowed to discard a function > call simply because it knows the result. A simpler example is > > #include > INTEGER I, F extern int f(void); > EXTERNAL F int main(void) { > int i; > I = 0*F() i = 0*f(); > PRINT *, I printf("%d\n", i); > END return 0; > } > > A Fortran compiler is allowed to say "hey, I know the result of 0*F() > without calling F, so I won't call F". A C compiler is not. This is not technically true. The C compiler may inline the function f(), and upon realizing that it has no global side effects (if this is true) will have the option of optimizing the f() away. I find it odd, if your claim is true, that a Fortran compiler would simply neglect to call F() no matter what. Isn't it possible for F() to modify a common/global? -- Paul Hsieh http://www.geocities.com/SiliconValley/9498/mailme.html