Q: Why did
printf("%d %d", f1(), f2());call f2 first? I thought the comma operator guaranteed left-to-right evaluation.
A: The comma operator does guarantee left-to-right evaluation, but the commas separating the arguments in a function call are not comma operators. [footnote] The order of evaluation of the arguments to a function call is unspecified. (See question 11.33.)
References:
K&R1 Sec. 3.5 p. 59
K&R2 Sec. 3.5 p. 63
ISO Sec. 6.3.2.2
H&S Sec. 7.10 p. 224