@@ -5890,6 +5890,11 @@ perfect_candidate_p (z_candidate *cand)
{
if (cand->viable < 1)
return false;
+ /* CWG1402 makes an implicitly deleted move op worse than other
+ candidates. */
+ if (DECL_DELETED_FN (cand->fn) && DECL_DEFAULTED_FN (cand->fn)
+ && move_fn_p (cand->fn))
+ return false;
int len = cand->num_convs;
for (int i = 0; i < len; ++i)
if (!perfect_conversion_p (cand->convs[i]))
new file mode 100644
@@ -0,0 +1,20 @@
+// PR c++/100644
+// { dg-do compile { target c++11 } }
+
+struct NonMovable {
+ NonMovable(NonMovable&&) = delete;
+};
+
+template <class T>
+struct Maybe {
+ NonMovable mMember;
+
+ template <typename U>
+ Maybe(Maybe<U>&&);
+};
+
+void foo(Maybe<int>);
+
+void unlucky(Maybe<int>&& x) {
+ Maybe<int> var{(Maybe<int>&&)x};
+}