Are a+=k and a=a+b different in c?
问题 I tried to swap without a template and I encountered this. Are a+=k and a=a+b different? What is wrong for first case? a += b-(b=a); // this print same value of two a and b. a = a + b-(b=a); // this thing correctly swapped values. 回答1: Both result in undefined behavior because you're both accessing and modifying b without an intervening sequence point: 6.5p2: If a side effect on a scalar object is unsequenced relative to either a different side effect on the same scalar object or a value