ambiguous ?

Richard O'Keefe ok at cs.mu.oz.au
Wed Oct 25 15:20:31 AEST 1989


In article <6658 at ficc.uu.net>, peter at ficc.uu.net (Peter da Silva) writes:
>     DATA I /0/
>     J = I * GETCH(5)
>     J = 0 * GETCH(6)

> Is this legal?
Yes (CF=0.9)
> Is it guaranteed that GETCH(5) will be evaluated?
If I is not modified elsewhere in the subprogram, no it is not.
A Fortran compiler is allowed to exploit identities such as 0*X = 0
> Is it guaranteed that GETCH(6) will be evaluated?
No.

(Giles)
> >       if (getch(5) && getch(6)) {...}

In the Fortran equivalent
	IF (GETCH(5) .AND. GETCH(6)) ...
either operand may be evaluated first, and the other may or may not
be evaluated depending on the outcome and the compiler-writer's choice.
This is what it _means_ to exploit the mathematical properties of "and"
as Giles recommends.



More information about the Comp.lang.c mailing list