https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85577
Bug ID: 85577 Summary: list-initialization chooses initializer-list constructor Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- namespace std { typedef long unsigned int size_t; template<class _E> class initializer_list { public: typedef _E value_type; typedef const _E& reference; typedef const _E& const_reference; typedef size_t size_type; typedef const _E* iterator; typedef const _E* const_iterator; private: iterator _M_array; size_type _M_len; constexpr initializer_list(const_iterator __a, size_type __l) : _M_array(__a), _M_len(__l) { } public: constexpr initializer_list() : _M_array(0), _M_len(0) { } constexpr size_type size() { return _M_len; } constexpr const_iterator begin() { return _M_array; } constexpr const_iterator end() { return begin() + size(); } }; template<typename T> T&& move(T& t) { return static_cast<T&&>(t); } template<typename T> struct vector { vector(vector&&) noexcept { } vector(initializer_list<T>) = delete; }; } struct A { A(A const&) = delete; A& operator=(A const&) = delete; A(A&&) = default; A& operator=(A&&) = default; A(std::vector<A>&& v) : v{std::move(v)} { } std::vector<A> v; }; v.ii: In constructor ‘A::A(std::vector<A>&&)’: v.ii:54:41: error: use of deleted function ‘std::vector<T>::vector(std::initializer_list<T>) [with T = A]’ A(std::vector<A>&& v) : v{std::move(v)} { } ^ v.ii:45:5: note: declared here vector(initializer_list<T>) = delete; ^~~~~~ The move constructor should be used, not the initialize-list one.