This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 112e. See for the official list.


2056. Member function calls in partially-initialized class objects

Section: 11.9.3  [class.base.init]     Status: drafting     Submitter: Richard Smith     Date: 2014-12-11

According to 11.9.3 [class.base.init] paragraph 16,

Member functions (including virtual member functions, 11.7.3 [class.virtual]) can be called for an object under construction. Similarly, an object under construction can be the operand of the typeid operator ( [expr.typeid]) or of a dynamic_cast ( [expr.dynamic.cast]). However, if these operations are performed in a ctor-initializer (or in a function called directly or indirectly from a ctor-initializer) before all the mem-initializers for base classes have completed, the result of the operation is undefined.

The example in that paragraph reads, in significant part,

  class B {
    int f();

  class C {

  class D : public B, C {
    D() : C(f())  // undefined: calls member function
                  // but base \tcode{C} not yet initialized

However, the construction of B, the object for which the member function is being called) has completed its construction, so it is not clear why this should be undefined behavior.

(See also issue 1517.)