Skip to content

CWG914 Value-initialization of array types #1372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jfbastien opened this issue Nov 24, 2022 · 0 comments
Open

CWG914 Value-initialization of array types #1372

jfbastien opened this issue Nov 24, 2022 · 0 comments
Labels
EWG Evolution needs-revision Paper needs changes before it can proceed

Comments

@jfbastien
Copy link
Collaborator

jfbastien commented Nov 24, 2022

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.

@jfbastien jfbastien added EWG Evolution needs-revision Paper needs changes before it can proceed labels Nov 24, 2022
@jensmaurer jensmaurer added this to the 2023-telecon milestone Jan 25, 2023
@jensmaurer jensmaurer removed this from the 2023-telecon milestone Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EWG Evolution needs-revision Paper needs changes before it can proceed
Projects
None yet
Development

No branches or pull requests

2 participants