Created on 2014-12-11.00:00:00 last changed 121 months ago
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 (7.6.1.8 [expr.typeid]) or of a dynamic_cast (7.6.1.7 [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 { public: int f(); }; class C { public: C(int); }; class D : public B, C { public: 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.)
History | |||
---|---|---|---|
Date | User | Action | Args |
2014-12-11 00:00:00 | admin | create |