[Bug c++/76262] New: list-initialization prefers initializer_list over copy constructor
barry.revzin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Aug 13 19:10:00 GMT 2016
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.
More information about the Gcc-bugs
mailing list