Infinite Loops

ron at brl-sem ron at brl-sem
Wed Apr 30 15:10:00 AEST 1986


> Unless you have a very unique optimizer, it is usually better to use the
> for(;;) form rather than the while(1) form.  Reason is:  while(1) is
> ALWAYS evaluated (ie. : is 1 TRUE? if so, continue) before each iteration,
> whereas for(;;) compiles as a simple branch or jump instruction with no
> test and no conditional branch.
> 
Crapola.  All the PCC impementations I've checked don't test the constant
even when you don't turn the optimizer on.  Our old PDP-11 Ritchie compiler
does generate the test, but the standard -O optimizer removes it.  Nothing
unique here.

-Ron



More information about the Comp.lang.c mailing list