This is true. I have my old dog eared C standard, but I don't care to reread the standard. volatile int x; : x = 123; this will cause x to be flushed from the register into memory (depending where x is defined.
x++; this will increment x in the register then store it in memory. In the case where x is a global variable, if it is not declared volatile, the compiler if free to keep its value in a register as long as it wishes. extern int x; { for(x = 0;x < MAX;x++) { do something; } In the above code, the compiler might maintain x in a register for the entire loop unless something in the loop forces it to be stored, but If the volatile keyword is used, x will be stored in its memory location when initialized to 0 and after it is incremented. But, volatile is not going to prevent the compiler from optimizing the loop by possibly living out a loop invariant or by unrolling it, etc. On 2 May 2002 at 16:04, Michael O'Donnell wrote: > IIRC, the C spec says that a specified change > to a given datum is supposed to be "complete" > a "sequence point" is reached which usually > corresponds in C to the semicolon which > terminates the corresponding statement. For a > given variable declared volatile, the compiler > is free to keep the results of intermediate > computations involving that datum anywhere it > likes, but must update the variable's "official" > location when it reaches the next sequence point. > This is where the constraints on the optimizer > come from; you've told it that it's still allowed > to optimize the code for any given statement or > group of statements, but all manipulations of > volatile data must play strictly by the rules > at the corresponding sequence points. > > This rules out register-resident variable in > most cases. -- 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. *****************************************************************