This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-19
P0145 caused this situation:
extern "C" void abort(); struct A { int i; int data[10000]; } a; A& aref() { a.i++; return a; } int main() { aref() = a; if (a.i != 0) abort(); }
Is a.i now required to be 0?
A related example is this:
int b; int& bref() { ++b; return b; } int main() { bref() = b; if (b != 0) abort(); }
Here, b is required to be 0 after the assignment, because the value computation of the RHS of the assignment is sequenced before any side-effects on the LHS. The difference in guaranteed behavior between class and non-class types is disturbing.
Rationale (April, 2017):
Class copy assignment binds a const T&, so the A example actually yields a.i == 1 after the assignment.