This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/76262] list-initialization prefers initializer_list over copy constructor
- From: "rs2740 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 16 Aug 2016 04:05:37 +0000
- Subject: [Bug c++/76262] list-initialization prefers initializer_list over copy constructor
- Authentication-results: sourceware.org; auth=none
- Auto-submitted: auto-generated
- References: <bug-76262-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=76262
TC <rs2740 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rs2740 at gmail dot com
--- Comment #1 from TC <rs2740 at gmail dot com> ---
Post-DR2137, [dcl.init.list]/3.1 no longer applies to non-aggregates. Instead,
[dcl.init.list]/3.6 applies:
> Otherwise, if T is a class type, constructors are considered.
> The applicable constructors are enumerated and the best one
> is chosen through overload resolution ([over.match],
> [over.match.list]).
And [over.match.list] makes clear that initializer-list constructors are
preferred if at all viable:
> When objects of non-aggregate class type T are list-initialized
> such that [dcl.init.list] specifies that overload resolution
> is performed according to the rules in this section, overload
> resolution selects the constructor in two phases:
> - Initially, the candidate functions are the initializer-list
> constructors ([dcl.init.list]) of the class T and the argument
> list consists of the initializer list as a single argument.
[over.ics.rank] is irrelevant because the non-initializer-list constructors are
not even candidates.