Dave Dunfield wrote:
Now, tell me what will be printed:
int i = 0;
i = i++;
printf("%d\n", i);
Again, it depends on the compiler vendor's definition of an
execution unit (maybe I'm using old terminology here?). If the
vendor says that the sub-expression evaluation is an execution
unit, then i will evaluate to 0, the incrementation operator
will be honored at the end of the execution unit (i now 1) then
the result of the previous evaluation will be stored in i, setting
i back to 0, the value it will have at the printf. If the vendor
says that the assignment is an execution unit, then i will evaluate
to 0, 0 will be stored back into i, then the incrementation operator
will be honored at the end of the execution unit, resulting in i
being 1 at the printf.