Title
Undefined behavior for constructor preconditions and destructor postconditions
Status
open
Section
11.9.3 [class.base.init]
Submitter
Joshua Berne

Created on 2026-07-15.00:00:00 last changed 1 week ago

Messages

Date: 2026-09-01.17:38:03

Suggested resolution:

Change in 11.9.3 [class.base.init] paragraph 18 as follows:

Member functions (including virtual member functions, 11.7.3 [class.virtual]) can be called for an object under construction or destruction. Similarly, an object under construction or destruction 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 during evaluation of
  • 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,
  • a precondition assertion of a constructor of the object under construction, or
  • a postcondition assertion of a the destructor of the object under destruction (9.4.1 [dcl.contract.func]),
the program has undefined behavior (F.6.3 [ub:class.base.init.mem.fun]).
Date: 2026-07-15.00:00:00

(From submission #948.)

The phrasing in 11.9.3 [class.base.init] paragraph 18 is missing (intended) restrictions on which constructors and destructors are in scope.

History
Date User Action Args
2026-08-23 08:17:32adminsetmessages: + msg8662
2026-07-15 00:00:00admincreate