Created on 2015-11-06.00:00:00 last changed 93 months ago
Proposed resolution (November, 2016):
Change 9.5 [dcl.init] bullet 6.2 as follows:
To zero-initialize an object or reference of type T means:
if T is a scalar type (6.9 [basic.types]), the object is initialized to the value obtained by converting the integer literal 0 (zero) to T;103
if T is a (possibly cv-qualified) non-union class type, each non-static data member, each non-virtual base class subobject, and, if the object is not a base class subobject, each virtual base
-class subobject is zero-initialized and padding is initialized to zero bits;...
[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.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2018-02-27 00:00:00 | admin | set | messages: + msg6162 |
| 2018-02-27 00:00:00 | admin | set | status: open -> c++17 |
| 2015-11-06 00:00:00 | admin | create | |