unsigned char x=1; x=(x++)<<3;
x=(++x)<<3; works it gives 16
Welcome to the wonderful club comprised of those bitten by race conditions. We'll get you your membership card tomorrow. In point of fact, there doesn't need to be an index in this expression to cause a problem. Essentially, if you have interrupt-driven code, you must imagine that any instruction that is not "atomic" (i.e. completed without interruption) can be stopped in the middle. Thus, something as simple as
a = b;