On 2 May 2002 at 14:38, Warren Mansur wrote:
> If I'm reading what you said correctly, then the volatile keyword is still
> performing as intended. I.e., if the variable must be saved after
> modification, then the compiler can't optimize out the for loop. It must
> increment the variable i until the test condition is false.
No. It does not need to execute that loop at all. All it needs to do is to 
return the initial value of 'iterations'. You can see that by compiling the 
code I sent you and disassembling it. 

> Yes, it may optimize by putting it into a register so the entire loop is
> executed within the processor (no fetches from RAM). But, AFAIK the
> compiler is always free to put any variables it wants to into registers.
> 
> Am I missing something??
If you declare 'i' as volatile and assuming you force the compiler to 
actually generate the loop by adding more code, the compiler will store 'i' 
immediately after incrementing it.  
--
Jerry Feldman <[EMAIL PROTECTED]>
Associate Director
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9


*****************************************************************
To unsubscribe from this list, send mail to [EMAIL PROTECTED]
with the text 'unsubscribe gnhlug' in the message body.
*****************************************************************

Reply via email to