I started a couple of weeks ago, when I received an email from Sandeep Vasant from Ahmedabad University in India. For reasons that he has yet to reveal, he was having trouble with some code like this:
int a=10, b=20, c=0;
c = a++ + a++ + b++ + b++ + ++a + ++b;
He tried this with one compiler and the resulting values of a, b and c were 13, 23 and 96 respectively. He was satisfied with this result. Then he tried a different compiler, which yielded a final value for c of 98, which he found confusing.
I started looking into this, certain that the explanation was simple … Read the rest of this entry »