Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!mips!gumby!lai From: lai@mips.COM (David Lai) Newsgroups: comp.std.c Subject: assignment to/from volatile execution sequence Keywords: abstract machine Message-ID: <36669@mips.mips.COM> Date: 5 Mar 90 03:11:01 GMT Sender: news@mips.COM Lines: 42 In a simple expression: a = b = c; where: int a,c; volatile int b; In determining the value to be assigned to a, the standard says in section 3.3.16, "An assignment expression has the value of the left operand after the assignment". Suppose 'b' is volatile, then we can't expect the value of b after the assignment to have any relation to the value stored into it (namely c). So the question is, can a=b=c be implemented as b=c, a=c. Or does the standard force it to be implemented as: b=c, a=b. I give an example, suppose 'b' is an I/O port, writing to b outputs a character, and reading b reads an input character. This is a case where reading the value of b may not necessarily be the value written to it. So the programmer writes: a=b=c; expecting to output the value c, and inputting an unknown value into a. The value of the left hand side (of b=c), after the assignment, may not be c. Can an implementation "expect" the value of "b=c" to be "c"? Another related question, does the left hand side have to be fully evaluated to determine the value of an assignment expression: a = *(complicated_expression_with_side_effects) = c; In other words, will the complicated_expression_with_side_effects be evaluated once or twice when the above statement is executed. Example: int a,*b,c; a = *(b++) = c; /* will b be incremented twice? */ -- "What is a DJ if he can't scratch?" - Uncle Jamms Army David Lai (lai@mips.com || {ames,prls,pyramid,decwrl}!mips!lai)