Skip to content

[dcl.init.aggr] Narrowing Conversions in Brace-Enclosed initializer-lists for Aggregate Initialization #686

Open
@ckwastra

Description

@ckwastra

Full name of submitter: Vincent X

Reference: [dcl.init.aggr]

Issue description: The corrent wording of [dcl.init.aggr]/4.3:

  • Otherwise, the initializer list is a brace-enclosed initializer-list. If an initializer-clause appertains to the aggregate element, then the aggregate element is copy-initialized from the initializer-clause. Otherwise, the aggregate element is copy-initialized from a brace-enclosed initializer-list consisting of all of the initializer-clauses that appertain to subobjects of the aggregate element, in the order of appearance.

lacks a prohibition on narrowing conversions. This branch was split from [dcl.init.aggr]/4.2 (emphasis mine):

  • Otherwise, the element is copy-initialized from the corresponding initializer-clause or is initialized with the brace-or-equal-initializer of the corresponding designated-initializer-clause. If that initializer is of the form assignment-expression or = assignment-expression and a narrowing conversion ([dcl.init.list]) is required to convert the expression, the program is ill-formed.

by P3106R1, but that revision didn't retain the wording prohibiting narrowing conversions, as shown above.

Suggested resolution: Amend [dcl.init.aggr]/4.3 as follows:

  • Otherwise, the initializer list is a brace-enclosed initializer-list. If an initializer-clause appertains to the aggregate element, then the aggregate element is copy-initialized from the initializer-clause. If that initializer is of the form assignment-expression and a narrowing conversion ([dcl.init.list]) is required to convert the expression, the program is ill-formed. Otherwise, the aggregate element is copy-initialized from a brace-enclosed initializer-list consisting of all of the initializer-clauses that appertain to subobjects of the aggregate element, in the order of appearance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions