Created on 2024-02-09.00:00:00 last changed 4 days ago
Proposed resolution (approved by CWG 2024-04-05):
Change in 6.7.4 [basic.life] paragraph 1 as follows:
The lifetime of an object or reference is a runtime property of the object or reference. A variable is said to have vacuous initialization if it is default-initialized, no other initialization is performed, and, if it is of class type or a (possibly multidimensional) array thereof, a trivial constructor of that class typehas a trivial default constructoris selected for the default-initialization. The lifetime of an object of type T begins when: ...
Change in 9.4.1 [dcl.init.general] paragraph 9 as follows:
To value-initialize an object of type T means:
- If T is a (possibly cv-qualified) class type (Clause 11 [class]), then
let C be the constructor selected to default-initialize the object, if any. If C is not user-provided, the object is first zero-initialized. In all cases, the object is then default-initialized.
- if T has either no default constructor (11.4.5.2 [class.default.ctor]) or a default constructor that is user-provided or deleted, then the object is default-initialized;
- otherwise, the object is zero-initialized and then default-initialized.
- ...
[Accepted as a DR at the June, 2024 meeting.]
(From submission #501.)
Subclause 9.4.1 [dcl.init.general] paragraph 9 specifies (as modified by issue 2820):
To value-initialize an object of type T means:
- If T is a (possibly cv-qualified) class type (Clause 11 [class]), then
- if T has either no default constructor (11.4.5.2 [class.default.ctor]) or a default constructor that is user-provided or deleted, then the object is default-initialized;
- otherwise, the object is zero-initialized and then default-initialized.
- ...
Per the specification, no zero-initialization occurs if the class has any user-provided default constructor, even if that constructor is not actually selected for the default initialization. This is observable in a constant expression, where reads of uninitialized data members are ill-formed.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-12-17 09:54:02 | admin | set | status: dr -> drwp |
2024-07-20 13:52:34 | admin | set | status: ready -> dr |
2024-06-27 04:25:11 | admin | set | status: tentatively ready -> ready |
2024-04-05 21:08:10 | admin | set | status: open -> tentatively ready |
2024-02-11 22:24:22 | admin | set | messages: + msg7604 |
2024-02-09 00:00:00 | admin | create |