On 10/5/06, Ricard Wanderlof <ricard.wanderlof@xxxxxxxx> wrote:
On Wed, 4 Oct 2006, Jinesh K J wrote: > operation is performed. When you write > > a = b; > > read operation is required on 'b', and a write on 'a'. But when you say > > a; // no operation is specified here > > or > > ; // an empty statement > > neither read nor a write is asked to perform by us. The compiler will I'm not too sure about this; when you say a; it's actually an expression that has the value a . The fact that you don't use that value means that the compiler will probably optimize away the statement entirely, if optimization is enabled. But this is not the same case as taking the address of something in which no read is attempted at all. But now we're getting far from kernel territory and into C and compiler details.
But, let us clear things up before leaving the topic off. With reference to ISO/IEC 9899:1999(E), the following could be observed: ========Page 132======== 6.8.3 Expression and null statements Syntax expression-statement: expressionopt ; Semantics - The expression in an expression statement is evaluated as a void expression for its side effects. - A null statement (consisting of just a semicolon) performs no operations. ============end============= As can be observed, the expression is evaluated as a void expression. ie, a; is evaluated as (void)a; // i hope so So now let us see what happens to a void expression: =========Page 47========== 6.3.2.2 void The (nonexistent) value of a void expression (an expression that has type void) shall not be used in any way, and implicit or explicit conversions (except to void) shall not be applied to such an expression. If an expression of any other type is evaluated as a void expression, its value or designator is discarded. (A void expression is evaluated for its side effects.) =============end============= Two things can be observed here: - value of a void expression shall not be used in any way - If an expression of any other type(which included our variable 'a') is evaluated as a void expression, its value or designator is discarded. - Here there are no side effects( no function call, assignments, etc) I hope my observations are correct. Regards, Jinesh. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/