Skip to content

CWG2859 [dcl.init.general] Value-initialization and multiple default constructors #501

Description

@t3nsor

Full name of submitter: Brian Bi

Reference (section label): [dcl.init.general]

Issue description: As pointed out on cppreference, the standard appears to say that if any default constructor is user-provided, then value-initialization does not first zero-initialize; but implementations appear to zero-initialize as long as the selected default constructor is not user-provided. I think the latter behavior is probably the intent of the standard.

Suggested resolution: This resolution is relative to the tentatively ready resolution of CWG2820.

Edit [dcl.init.general]/9.1 as follows:

If T is a (possibly cv-qualified) class type ([class]), then let C be the constructor selected to default-initialize an object of type T. If C is not user-provided, the object is first zero-initialized. Regardless of whether such zero-initialization was performed, the object is then default-initialized.

  • if T has either no default constructor ([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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions