https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102050

            Bug ID: 102050
           Summary: Nonempty list-initialization rejects constructor with
                    defaulted std::initializer_list
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
                CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/5PGza1o8e.
```C++
#include <initializer_list>
struct S { S( std::initializer_list<int> = {} ) {} };
int main() { S{0}; }
```
```
<source>: In function 'int main()':
<source>:3:17: error: no matching function for call to 'S::S(<brace-enclosed
initializer list>)'
    3 | int main() { S{0}; }
      |                 ^
<source>:2:12: note: candidate: 'S::S(std::initializer_list<int>)'
    2 | struct S { S( std::initializer_list<int> = {} ) {} };
      |            ^
<source>:2:15: note:   no known conversion for argument 1 from 'int' to
'std::initializer_list<int>'
    2 | struct S { S( std::initializer_list<int> = {} ) {} };
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:2:8: note: candidate: 'constexpr S::S(const S&)'
    2 | struct S { S( std::initializer_list<int> = {} ) {} };
      |        ^
<source>:2:8: note:   no known conversion for argument 1 from 'int' to 'const
S&'
<source>:2:8: note: candidate: 'constexpr S::S(S&&)'
<source>:2:8: note:   no known conversion for argument 1 from 'int' to 'S&&'
Compiler returned: 1
```

This came up at https://cpplang.slack.com/archives/C2SLQATS9/p1629835850325200.

Reply via email to