Title
Base classes of virtual base classes
Status
open
Section
6.8.4 [basic.life]
Submitter
Lénárd Szolnoki

Created on 2026-06-24.00:00:00 last changed 2 days ago

Messages

Date: 2026-06-29.21:20:39

Possible resolution:

  1. Change in 6.8.4 [basic.life] bullet 7.3 as follows:

    ... The program has undefined behavior if
    • ...
    • the pointer is converted (7.3.12 [conv.ptr], 7.6.1.9 [expr.static.cast]) to a pointer to a transitively virtual base class or to a base class thereof (11.7.2 [class.mi]), or
    • ...
  2. Change in 6.8.4 [basic.life] paragraph 8.3 as follows:

    The program has undefined behavior if
    • ...
    • the glvalue is bound to a reference to a transitively virtual base class (9.5.4 [dcl.init.ref], 11.7.2 [class.mi]), or
    • ...
  3. Change in 7.3.12 [conv.ptr] paragraph 3 as follows:

    ... Otherwise, if B is a transitively virtual base class of D or is a base class of a virtual base class of D (11.7.2 [class.mi]) 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. ...
  4. Change in 7.3.13 [conv.mem] paragraph 2 as follows:

    ... If B is an inaccessible (11.8 [class.access]), ambiguous (6.5.2 [class.member.lookup]), or transitively virtual (11.7.2 [class.mi]) base class of D, or a base class of a virtual base class of D, a program that necessitates this conversion is ill-formed. ...
  5. Change in 7.6.1.9 [expr.static.cast] paragraph 2 as follows:

    ... If B is a transitively virtual base class of D or a base class of a virtual base class of D, (11.7.2 [class.mi]) or if no valid standard conversion from “pointer to D” to “pointer to B” exists (7.3.12 [conv.ptr]), the program is ill-formed. ...
  6. Change in 7.6.1.9 [expr.static.cast] paragraph 10 as follows:

    ... If B is a transitively virtual base class of D or a base class of a virtual base class of D, (11.7.2 [class.mi]) or if no valid standard conversion from “pointer to D” to “pointer to B” exists (7.3.12 [conv.ptr]), the program is ill-formed. ...
  7. Change in 11.7.2 [class.mi] paragraph 4 as follows:

    A base class specifier that does not contain the keyword virtual specifies a non-virtual base class. A base class specifier that contains the keyword virtual specifies a virtual base class. For each distinct occurrence of a non-virtual base class in the class lattice of the most derived class, the most derived object (6.8.2 [intro.object]) shall contain contains a corresponding distinct base class subobject of that type. For each distinct base class that is specified virtual, the most derived object shall contain contains a single base class subobject of that type. A transitively virtual base class is a virtual base class or a base class thereof.
Date: 2026-06-24.00:00:00

(From submission #936.)

Rules that apply to virtual base classes should often also apply to base classes of virtual base classes. Subclause 6.8.4 [basic.life] paragraph 8 is lacking in that regard.

History
Date User Action Args
2026-06-29 21:20:39adminsetmessages: + msg8623
2026-06-24 00:00:00admincreate