Skip to content
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

[dcl.init.aggr] Does p9 apply to function-style casts? #2012

Closed
cpplearner opened this issue Apr 2, 2018 · 0 comments
Closed

[dcl.init.aggr] Does p9 apply to function-style casts? #2012

cpplearner opened this issue Apr 2, 2018 · 0 comments
Assignees

Comments

@cpplearner
Copy link
Contributor

[dcl.init.aggr]/9:

An array of unknown bound initialized with a brace-enclosed initializer-list containing n initializer-clauses, where n shall be greater than zero, is defined as having n elements ([dcl.array]).

[dcl.array]/3:

An array bound may also be omitted when the declarator is followed by an initializer or when a declarator for a static data member is followed by a brace-or-equal-initializer ([class.mem]). In both cases the bound is calculated from the number of initial elements (say, N) supplied ([dcl.init.aggr]), and the type of the identifier of D is “array of N T”.

[expr.type.conv]/2:

Otherwise, the expression is a prvalue of the specified type whose result object is direct-initialized with the initializer.

Consider

using T = int[];
auto&& r = T{1,2};

Should r have type int(&&)[2] or int(&&)[] (or be ill-formed, since T is an incomplete type)?

[dcl.init.aggr]/9 seems to imply that the array bound is deduced in this case, but [dcl.array]/3 and [expr.type.conv]/2 seem more ambiguous.

All compilers I tested say that r has type int(&&)[2].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants