Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!decwrl!apple!sun-barr!newstop!sun!amdahl!key!sjc From: sjc@key.COM (Steve Correll) Newsgroups: comp.lang.fortran Subject: Re: Side effects in boolean expressions Message-ID: <2047@key.COM> Date: 16 Aug 90 19:20:56 GMT References: <2022@key.COM> <59110@lanl.gov> <2041@key.COM> <140684@sun.Eng.Sun.COM> Organization: Key Computer Labs, Fremont, CA Lines: 17 In article <140684@sun.Eng.Sun.COM>, wsb@boise.Eng.Sun.COM (Walt Brainerd) writes: > In article <2041@key.COM>, sjc@key.COM (Steve Correll) writes: > > ... the C code is legal and its behavior predictable; the Fortran is neither: > > ^^^^^^^^^^^^^^^^^^^^^^ > > if ((x < 0.0) || (sqrt(x) < 10.0)) ... > > IF ((X .LT. 0.) .OR. (SQRT(X) .LT. 10.0)) ... > > > The Fortran code certainly is legal... I believe that a program which could cause the translator to invoke SQRT with a negative argument fails to conform to the Fortran 77 standard, because section 13.10.1, page 15-28 of the X3.9-1978 says: Square Root: The value of the argument of SQRT and DSQRT must be greater than or equal to zero. -- ...{sun,pyramid}!pacbell!key!sjc Steve Correll