This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/65622] New: No known conversion to initializer_list with default argument in constructor
- From: "david.d.kretzmer at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 30 Mar 2015 00:50:34 +0000
- Subject: [Bug c++/65622] New: No known conversion to initializer_list with default argument in constructor
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65622
Bug ID: 65622
Summary: No known conversion to initializer_list with default
argument in constructor
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: david.d.kretzmer at gmail dot com
------------------------------------------------
#include <initializer_list>
struct Foo
{
Foo(std::initializer_list<int> = {}) {}
};
Foo f{1};
------------------------------------------------
The above code produces the following error (tested in 4.7, 4.8 and 4.9):
error: no matching function for call to 'Foo::Foo(<brace-enclosed initializer
list>)'
note: candidates are:
note: constexpr Foo::Foo(const Foo&)
note: no known conversion for argument 1 from 'int' to 'const Foo&'
note: constexpr Foo::Foo(Foo&&)
note: no known conversion for argument 1 from 'int' to 'Foo&&'
note: Foo::Foo(std::initializer_list<int>)
note: no known conversion for argument 1 from 'int' to
'std::initializer_list<int>'
When I remove the default argument it compiles without errors.
The error only occurs in constructors, normal functions are not affected.