This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


1097. Aggregate initialization of function parameters

Section: 9.4.2  [dcl.init.aggr]     Status: NAD     Submitter: Daniel Krügler     Date: 2010-07-29

The current wording of the WP allows aggregate initialization of parameters in function calls. For example, 12.2.4.2.6 [over.ics.list] paragraph 4 reads:

Otherwise, if the parameter has an aggregate type which can be initialized from the initializer list according to the rules for aggregate initialization (9.4.2 [dcl.init.aggr]), the implicit conversion sequence is a user-defined conversion sequence. [Example:

  struct A {
    int m1;
    double m2;
  };

  void f(A);
  f( {'a', 'b'} );  // OK: f(A(int,double)) user-defined conversion
  f( {1.0} );       // error: narrowing

end example]

The rules for aggregate initialization in 9.4.2 [dcl.init.aggr] paragraph 11 allow braces to be elided in the initializer

In a declaration of the form

  T x = { a };

It is not clear whether this phrasing should be interpreted as allowing brace elision only in a simple-declaration and thus not in a function argument or whether this restriction is inadvertent and should be removed.

Rationale (November, 2010):

The restriction is intentional. Support for aggregate initialization is principally intended for legacy code and C compatibility, not for code written using the new facilities of the language.