This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-09-13
According to 6.8.4 [basic.life] paragraph 7, converting a pointer-to-derived to pointer-to-base for an out-of-lifetime object is allowed implicitly, but disallowed using static_cast. That seems inconsistent.
Furthermore, base classes of virtual base classes should get the same treatment as virtual base classes themselves.
Possible resolution:
Change 7.3.12 [conv.ptr] paragraph 3 as follows:
... Otherwise, if B is a virtual base class of D or is a base class of a virtual base class of D and v does not point to an object whose type is similar (7.3.6 [conv.qual]) to D and that is within its lifetime or within its period of construction or destruction (11.9.5 [class.cdtor]), the behavior is undefined. ...
Change in 6.8.4 [basic.life] paragraph 7 as follows:
Before the lifetime of an object has started but after the storage which the object will occupy has been allocated [ Footnote: ...] ... The program has undefined behavior if
- the pointer is used as the operand of a delete-expression,
- the pointer is used to access a non-static data member or call a non-static member function of the object,
or- the pointer is
implicitlyconverted (7.3.12 [conv.ptr], 7.6.1.9 [expr.static.cast]) to a pointer to a virtual base class or to a base class thereof, or- the pointer is used as the operand of a static_cast (7.6.1.9 [expr.static.cast]), except when the conversion is to pointer to cv void, or to pointer to cv void and subsequently to pointer to cv char, cv unsigned char, or cv std::byte (17.2.1 [cstddef.syn]), or
- the pointer is used as the operand of a dynamic_cast (7.6.1.7 [expr.dynamic.cast]).