This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/76262] New: list-initialization prefers initializer_list over copy constructor
- From: "barry.revzin at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 13 Aug 2016 19:09:49 +0000
- Subject: [Bug c++/76262] New: list-initialization prefers initializer_list over copy constructor
- Authentication-results: sourceware.org; auth=none
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=76262
Bug ID: 76262
Summary: list-initialization prefers initializer_list over copy
constructor
Product: gcc
Version: 6.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
In this example:
#include <iostream>
struct X {
X(std::initializer_list<int >) { std::cout << '1'; }
X(X const& ) { std::cout << '2'; }
operator int() { return 0; }
};
int main() {
X x{1};
X y{x};
}
gcc 5.3, 6.1, and 7.0 all print 11. But the wording in [over.ics.rank] favoring
initializer_list<X> only applies if the conversion sequences are of the same
form, and in this case they're not - the initializer_list<X> constructor
requires a user-defined conversion.