Title
Default initialization of POD classes?
Status
cd1
Section
11.9 [class.init]
Submitter
Mike Miller

Created on 2005-03-18.00:00:00 last changed 161 months ago

Messages

Date: 2006-04-15.00:00:00

[Voted into WP at April, 2006 meeting.]

Date: 2005-10-15.00:00:00

Proposed resolution (October, 2005):

Remove the indicated words from 11.9 [class.init] paragraph 1:

When no initializer is specified for an object of (possibly cv-qualified) class type (or array thereof), or the initializer has the form (), the object is initialized as specified in 9.4 [dcl.init]. The object is default-initialized if there is no initializer, or value-initialized if the initializer is ().
Date: 2005-03-18.00:00:00

9.4 [dcl.init] paragraph 10 makes it clear that non-static POD class objects with no initializer are left uninitialized and have an indeterminate initial value:

If no initializer is specified for an object, and the object is of (possibly cv-qualified) non-POD class type (or array thereof), the object shall be default-initialized; if the object is of const-qualified type, the underlying class type shall have a user-declared default constructor. Otherwise, if no initializer is specified for a non-static object, the object and its subobjects, if any, have an indeterminate initial value; if the object or any of its subobjects are of const-qualified type, the program is ill-formed.

11.9 [class.init] paragraph 1, however, implies that all class objects without initializers, whether POD or not, are default-initialized:

When no initializer is specified for an object of (possibly cv-qualified) class type (or array thereof), or the initializer has the form (), the object is initialized as specified in 9.4 [dcl.init]. The object is default-initialized if there is no initializer, or value-initialized if the initializer is ().
History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2006-11-05 00:00:00adminsetstatus: dr -> wp
2006-04-22 00:00:00adminsetmessages: + msg1366
2006-04-22 00:00:00adminsetstatus: ready -> dr
2005-10-22 00:00:00adminsetmessages: + msg1223
2005-10-22 00:00:00adminsetstatus: open -> ready
2005-03-18 00:00:00admincreate