CWG Issue 2196 (original) (raw)

This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-11-05


2196. Zero-initialization with virtual base classes

Section: 9.5 [dcl.init]Status: C++17Submitter: Richard SmithDate: 2015-11-06

[Adopted at the February/March, 2017 meeting.]

Consider:

struct V { int n; }; struct A : virtual V {}; struct B : A { B() : V{123}, A() {} } b;

Initialization of b first performs aggregate initialization of the V virtual base subobject. Then it performs value initialization of the A base subobject. Per 9.5.1 [dcl.init.general] bullet 9.1.2, the A base subobject is zero-initialized. Per 9.5.1 [dcl.init.general] bullet 6.2, this zero-initializes the V virtual base subobject.

Result: b.n is required to be 0, not 123.

Proposed resolution (November, 2016):

Change 9.5 [dcl.init] bullet 6.2 as follows:

To zero-initialize an object or reference of type Tmeans: