[sv-bc] Question on 1800 section 8.3

From: Stuart Sutherland <stuart_at_.....>
Date: Fri Sep 01 2006 - 04:22:12 PDT
Section 8.3 of the 1800 standard contains the following example and
explanation:

i = 10;
j = i++ + (i = i - 1);
After execution, the value of j can be 18, 19, or 20 depending upon the
relative ordering of the increment
and the assignment statements.

Can anybody detail the three orders of execution that would lead to these
three possible results? 

The only combinations I can come up with are:

j = 9 + 9 (i-1 is evaluated first, and used as the value of i++)

j = 10 + 9 (i used as the value for i++ first, and then i-1 is evaluated)

It seems to me that since i++ is a post-increment, it cannot change i until
after j has been assigned.

Thanks,

Stu
~~~~~~~~~~~~~~~~~~~~~~~~~
Stuart Sutherland
stuart@sutherland-hdl.com
+1-503-692-0898
 
Received on Fri Sep 1 04:22:19 2006

This archive was generated by hypermail 2.1.8 : Fri Sep 01 2006 - 04:23:28 PDT