bitwise short-circuiting
    News system 
    news at ism780c.UUCP
       
    Sat Feb 20 13:26:00 AEST 1988
    
    
  
Chris Torek writing about optimizing expressions like:
       a = 0 & f();
       (void) f(), a = 0
       if (1 | g()) s1; else s2;
says:
>(s2 may be deleted entirely iff it is not reachable via labels),
>and that unless the compiler can determine that f() and g() have
>no side effects, any further optimisation is simply wrong.
		  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>In-Real-Life: Chris Torek, Univ of MD Computer Science, +1 301 454 7163
Chris, how do you justify the above assertion?  I just got my copy of the
the proposed standard (11 Jan 88 version).  On page 51 the semantics of the
bitwise & operator is defined. I quote:
       "The usual arithmetic conversions are performed on the operands."
       "The result of the binary & operator is the bitwise AND of the
       operands (that is, each bit in the result is set if and only if
       each of the corresponding bits in the converted operands is set)."
I could not find any thing in the standard that requires evaluation of
side effects of the operands if the result can be determined without
evaluating the operands.
      Marv Rubinstein -- Interactive Systems
    
    
More information about the Comp.lang.c
mailing list