Skip to content

CWG914 Value-initialization of array types #1372

Description

@jfbastien

Migrating from https://isocpp.org/files/papers/P1018R18.html#issues
CWG914

Section: 7.6.1.4 [expr.type.conv] Status: extension Submitter: Gabriel Dos Reis Date: 10 June, 2009
Although value-initialization is defined for array types and the () initializer is permitted in a mem-initializer naming an array member of a class, the syntax T() (where is an array type) is explicitly forbidden by 7.6.1.4 [expr.type.conv] paragraph 2. This is inconsistent and the syntax should be permitted.

Rationale (July, 2009):

The CWG was not convinced of the utility of this extension, especially in light of questions about handling the lifetime of temporary arrays. This suggestion needs a proposal and analysis by the EWG before it can be considered by the CWG.

Although value-initialization is defined for array types and the () initializer is permitted in a mem-initializer naming an array member of a class, the syntax T() (where is an array type) is explicitly forbidden by 7.6.1.3 [expr.type.conv] paragraph 2. This is inconsistent and the syntax should be permitted.

Rationale (July, 2009): The CWG was not convinced of the utility of this extension, especially in light of questions about handling the lifetime of temporary arrays. This suggestion needs a proposal and analysis by the EWG before it can be considered by the CWG.

This has become a more severe inconsistency after we adopted Ville’s P0960 for C++20. Now it’s not only () that has this weird special-case restriction, it’s (a, b, c) too:

using X = int[];

X x{1, 2, 3}; // ok, int[3]

X y(1, 2, 3); // ok, int[3]

f(X{1, 2, 3}); // ok, int[3] temporary

f(X(1, 2, 3)); // error

Meeting: (notes) it is a defect, need a paper. David Stone trying to find a volunteer to write said paper. All in favor.

Activity

  1. added this to the 2023-telecon milestone on Jan 25, 2023
  2. removed this from the 2023-telecon milestone on Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    EWGEvolutionneeds-revisionPaper needs changes before it can proceed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions