Created on 2016-07-06.00:00:00 last changed 82 months ago
Rationale (April, 2017):
Class copy assignment binds a const T&, so the A example actually yields a.i == 1 after the assignment.
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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2018-02-27 00:00:00 | admin | set | messages: + msg6010 |
2016-07-06 00:00:00 | admin | create |