Title
Aggregate CTAD, string, and brace elision
Status
open
Section
12.2.2.9 [over.match.class.deduct]
Submitter
Jason Merrill

Created on 2020-07-14.00:00:00 last changed 2 weeks ago

Messages

Date: 2023-01-15.15:49:37

Suggested resolution:

Change in 12.2.2.9 [over.match.class.deduct] bullet 1.5 as follows:

For each xi, let ei be the corresponding aggregate element of C or of one of its (possibly recursive) subaggregates that would be initialized by xi (9.4.2 [dcl.init.aggr]) if
  • brace elision is not considered for any aggregate element that has
    • a dependent non-array type or ,
    • an array type with a value-dependent bound, or
    • a string literal as the corresponding initializer and that has an array type whose element type is a (possibly cv-qualified) template parameter or is a dependent type specified with a qualified-id whose nested-name-specifier is dependent or with a decltype-specifier; and
  • ...
Date: 2020-07-14.00:00:00

Consider:

  template <class T>
  struct A {
    T ar[4];
  };
  A a = { "foo" }; 

Subclause 12.2.2.9 [over.match.class.deduct] bullet 1.5 specifies:

For each xi, let ei be the corresponding aggregate element of C or of one of its (possibly recursive) subaggregates that would be initialized by xi (9.4.2 [dcl.init.aggr]) if
  • brace elision is not considered for any aggregate element that has a dependent non-array type or an array type with a value-dependent bound, and
  • ...

The normative rule does not properly consider arrays with dependent element type, initialized by a string literal. MSVC accepts, gcc and clang reject the example.

History
Date User Action Args
2023-01-15 15:49:37adminsetmessages: + msg7140
2020-07-14 00:00:00admincreate