这有个相同的例子。但后面有个注释,只在老版C++标准里是UB,新版的不是
https://en.cppreference.com/w/cpp/language/eval_order
If a side effect on a memory location is unsequenced relative to a value computation using the value of any object in the same memory location, the behavior is undefined.
cout << i << i++; // undefined behavior until C++17
从C++17开始不再是UB,chagpt给出的参考资料是:
https://www.cppstories.com/2021/evaluation-order-cpp17/
https://www.geeksforgeeks.org/order-of-evaluation-in-cpp-17/
【 在 lag 的大作中提到: 】
: 不等价 拆开后分号是序列点 连着写就没有序列点了 也不用考虑<<
: 就比如
: obj.f(i++).g(i++);
: ...................
--
修改:z16166 FROM 61.48.130.*
FROM 61.48.130.*