You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: