Keith Thompson said:
What would be the point? Don't waste time guessing what the code might
do for a given implementation. Just fix it.
OK, so we fix it so that the result is ....? Any guesses?
Changing the erroneous code so that it stays within the rules:
int i = 0;
int t1,t2,t3;
t1=++i;
t2=++i;
t3=++i;
i=t1+t2+t3;
printf("%d",i);
Now gives a valid result. Which happens to coincide with the OP's
expectations, and with what I said it *ought* to be (for which I was called
a 'nitwit', even though I went on to explain why the OP wasn't getting that
result), and in fact with what most of my compilers were already giving me
anyway; presumably they were already using code along the same lines!)
However, the interesting question is, why anyone - outside c.l.c obviously -
might think the output of the OP's original code might be 6, rather than any
other number (or any other manifestation, according to previous threads
along the same lines).
Or, are we not allowed to think or guess anything at all, simply because the
C standard says the original expression has undefined behaviour?