Created on 2000-06-28.00:00:00 last changed 286 months ago
Rationale (04/01):
Reallocation of a base class subobject is already disallowed by 6.7.3 [basic.life] paragraph 7.
6.7.3 [basic.life] and 11.4.7 [class.dtor] discuss explicit management of object lifetime. It seems clear that most object lifetime issues apply to sub-objects (array elements, and data members) as well. The standard supports
struct X { T t } x; T* pt = &x.t; pt->~T(); new(pt) T;
and this kind of behavior is useful in allocators.
However the standard does not seem to prohibit the same operations on base sub-objects.
struct D: B{ ... } d; B* pb = &d; pb->~B(); new(pb) B;
However if B and/or D have virtual member functions or virtual bases, it is unlikely that this code will result in a well-formed D object in current implementations (note that the various lines may be in different functions).
Suggested resolution: 11.4.7 [class.dtor] should be modified so that explicit destruction of base-class sub-objects be made illegal, or legal only under some restrictive conditions.
History | |||
---|---|---|---|
Date | User | Action | Args |
2001-05-20 00:00:00 | admin | set | messages: + msg519 |
2001-05-20 00:00:00 | admin | set | status: open -> nad |
2000-06-28 00:00:00 | admin | create |