Are there sequence points in the expression a^=b^=a^=b, or is it undefined?
问题 The allegedly "clever" (but actually inefficient) way of swapping two integer variables, instead of using temporary storage, often involves this line: int a = 10; int b = 42; a ^= b ^= a ^= b; /*Here*/ printf("a=%d, b=%d\n", a, b); But I'm wondering, compound assignment operators like ^= are not sequence points, are they? Does this mean it's actually undefined behavior? 回答1: a ^= b ^= a ^= b; /*Here*/ It is undefined behavior. You are modifying an object ( a ) more than once between two