Skip to content
Snippets Groups Projects
Commit dc7f1bfb authored by Jason Merrill's avatar Jason Merrill
Browse files

c++: fix explicit/copy problem [PR109247]

In the testcase, the user wants the assignment to use the operator= declared
in the class, but because [over.match.list] says that explicit constructors
are also considered for list-initialization, as affirmed in CWG1228, we end
up choosing the implicitly-declared copy assignment operator, using the
explicit constructor template for the argument, which is ill-formed.  Other
implementations haven't implemented CWG1228, so we keep getting bug reports.

Discussion in CWG led to the idea for this targeted relaxation: if we use an
explicit constructor for the conversion to the argument of a copy or move
special member function, that makes the candidate worse than another.

	DR 2735
	PR c++/109247

gcc/cp/ChangeLog:

	* call.cc (sfk_copy_or_move): New.
	(joust): Add tiebreaker for explicit conv and copy ctor.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/initlist-explicit3.C: New test.
parent 9da2ef36
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment