Must useless expressions be evaluated?

ark at rabbit.UUCP ark at rabbit.UUCP
Mon Oct 17 02:33:09 AEST 1983


Barry Margolin points out that if foo is a reducible function,
then the compiler is allowed to generate code for

	if bool_var | foo(x) then ...

which does not evaluate foo if bool_var is true.  This statement
is correct, but slightly misleading -- the PL/I implementation
I have used (and, if I recall correctly, the ANSI standard) permits
the compiler to use short-circuit evaluation in this context even
if foo is not reducible.  In general, the compiler is only obliged
to evaluate enough of an expression to determine its result.



More information about the Comp.lang.c mailing list