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

Initializer List #35

Closed
saxenark opened this issue Nov 21, 2012 · 1 comment
Closed

Initializer List #35

saxenark opened this issue Nov 21, 2012 · 1 comment
Assignees

Comments

@saxenark
Copy link

This issue is motivated by the discussion at http://isocpp.org/forums/iso-c-standard-discussion with the title "Initializer List"

The issue:

A braced-init-list is not treated as an expression. This is evident from the grammar in section 5.2.2.

and even in the paragraph 6.6.3/1-

"A return statement with neither an expression nor a braced-init-list can be used only in functions that do not return a value, that is, a function with the return type void"

Now,

Given a function

'void f(std::initializer_list t) { }
The function call 'f({1, 2}) is well-formed.

However, given the fact that a braced-init-list is not an expression, the wording in section 5.2.2 seems inappropriate to me as it accounts only for "expressions" to be allowed as function call arguments.

"There are two kinds of function call: ordinary function call and member function63 (9.3) call. A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of expressions which constitute the arguments to the function."

This statement possibly can be more permissive and explicitly mention about braced-init-list. My proposal is as follows:

"There are two kinds of function call: ordinary function call and member function63 (9.3) call. A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of expressions or braced-init-list which constitute the arguments to the function."

An alternate proposal is to treat a braced-init-list such as {1, 2} also as an expression.

@ghost ghost assigned zygoloid Mar 16, 2013
@zygoloid
Copy link
Member

Fixed in 5fcb9e8, along with two more references to arguments as 'expressions' in later non-normative text.

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