Created on 2016-06-20.00:00:00 last changed 81 months ago
[Moved to DR at the November, 2016 meeting.]
Proposed resolution (June, 2016):
Change 11.4.5 [class.ctor] paragraph 12 as follows:
During the construction of
a constan object, if the value of the object or any of its subobjects is accessed through a glvalue that is not obtained, directly or indirectly, from the constructor's this pointer, the value of the object or subobject thus obtained is unspecified. [Example:struct C; void no_opt(C*); struct C { int c; C() : c(0) { no_opt(this); } }; const C cobj; void no_opt(C* cptr) { int i = cobj.c * 100; // value of cobj.c is unspecified cptr->c = 1; cout << cobj.c * 100 // value of cobj.c is unspecified << '\n'; } extern struct D d; struct D { D(int a) : a(a), b(d.a) {} int a, b; }; D d = D(1); // value of d.b is unspecified—end example]
The restrictions against aliasing this inside a constructor should apply to all objects, not just to const objects.
History | |||
---|---|---|---|
Date | User | Action | Args |
2018-02-27 00:00:00 | admin | set | messages: + msg6166 |
2018-02-27 00:00:00 | admin | set | status: dr -> c++17 |
2017-02-06 00:00:00 | admin | set | messages: + msg6089 |
2016-06-20 00:00:00 | admin | create |